From 84ceca8747443e9e7331d1a714708d805db5f4b3 Mon Sep 17 00:00:00 2001 From: AmrDeveloper Date: Fri, 14 Jul 2023 13:47:28 +0200 Subject: [PATCH] Allow calling aggregation function with upper or lower case --- src/parser.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index f28eba64..2fe6818b 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -279,7 +279,8 @@ fn parse_select_statement( } // Check if aggregation function name is valid - if !AGGREGATIONS.contains_key(&field_name.as_str()) { + let function_name = field_name.to_lowercase(); + if !AGGREGATIONS.contains_key(function_name.as_str()) { return Err(GQLError { message: "Invalid GQL aggregation function name".to_owned(), location: field_name_location, @@ -287,12 +288,12 @@ fn parse_select_statement( } // Type check aggregation function argument type - let prototype = AGGREGATIONS_PROTOS.get(&field_name.as_str()).unwrap(); + let prototype = AGGREGATIONS_PROTOS.get(function_name.as_str()).unwrap(); let field_type = TABLES_FIELDS_TYPES.get(argument.literal.as_str()).unwrap(); if prototype.parameter != DataType::Any && field_type != &prototype.parameter { let message = format!( "Aggregation Function `{}` expect parameter type `{}` but got type `{}`", - field_name.to_string(), + function_name, &prototype.parameter.literal(), field_type.literal() ); @@ -338,7 +339,7 @@ fn parse_select_statement( aggregations.insert( column_name.to_string(), AggregateFunction { - function_name: field_name.to_string(), + function_name: function_name, argument: argument.literal.to_string(), }, );