@@ -1108,6 +1108,7 @@ fn parse_select_count_wildcard() {
11081108 assert_eq ! (
11091109 & Expr :: Function ( Function {
11101110 name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
1111+ uses_odbc_syntax: false ,
11111112 parameters: FunctionArguments :: None ,
11121113 args: FunctionArguments :: List ( FunctionArgumentList {
11131114 duplicate_treatment: None ,
@@ -1130,6 +1131,7 @@ fn parse_select_count_distinct() {
11301131 assert_eq ! (
11311132 & Expr :: Function ( Function {
11321133 name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
1134+ uses_odbc_syntax: false ,
11331135 parameters: FunctionArguments :: None ,
11341136 args: FunctionArguments :: List ( FunctionArgumentList {
11351137 duplicate_treatment: Some ( DuplicateTreatment :: Distinct ) ,
@@ -2366,6 +2368,7 @@ fn parse_select_having() {
23662368 Some ( Expr :: BinaryOp {
23672369 left: Box :: new( Expr :: Function ( Function {
23682370 name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
2371+ uses_odbc_syntax: false ,
23692372 parameters: FunctionArguments :: None ,
23702373 args: FunctionArguments :: List ( FunctionArgumentList {
23712374 duplicate_treatment: None ,
@@ -2396,6 +2399,7 @@ fn parse_select_qualify() {
23962399 Some ( Expr :: BinaryOp {
23972400 left: Box :: new( Expr :: Function ( Function {
23982401 name: ObjectName ( vec![ Ident :: new( "ROW_NUMBER" ) ] ) ,
2402+ uses_odbc_syntax: false ,
23992403 parameters: FunctionArguments :: None ,
24002404 args: FunctionArguments :: List ( FunctionArgumentList {
24012405 duplicate_treatment: None ,
@@ -2802,6 +2806,7 @@ fn parse_listagg() {
28022806 assert_eq ! (
28032807 & Expr :: Function ( Function {
28042808 name: ObjectName ( vec![ Ident :: new( "LISTAGG" ) ] ) ,
2809+ uses_odbc_syntax: false ,
28052810 parameters: FunctionArguments :: None ,
28062811 args: FunctionArguments :: List ( FunctionArgumentList {
28072812 duplicate_treatment: Some ( DuplicateTreatment :: Distinct ) ,
@@ -4603,6 +4608,7 @@ fn parse_named_argument_function() {
46034608 assert_eq ! (
46044609 & Expr :: Function ( Function {
46054610 name: ObjectName ( vec![ Ident :: new( "FUN" ) ] ) ,
4611+ uses_odbc_syntax: false ,
46064612 parameters: FunctionArguments :: None ,
46074613 args: FunctionArguments :: List ( FunctionArgumentList {
46084614 duplicate_treatment: None ,
@@ -4642,6 +4648,7 @@ fn parse_named_argument_function_with_eq_operator() {
46424648 assert_eq ! (
46434649 & Expr :: Function ( Function {
46444650 name: ObjectName ( vec![ Ident :: new( "FUN" ) ] ) ,
4651+ uses_odbc_syntax: false ,
46454652 parameters: FunctionArguments :: None ,
46464653 args: FunctionArguments :: List ( FunctionArgumentList {
46474654 duplicate_treatment: None ,
@@ -4716,6 +4723,7 @@ fn parse_window_functions() {
47164723 assert_eq ! (
47174724 & Expr :: Function ( Function {
47184725 name: ObjectName ( vec![ Ident :: new( "row_number" ) ] ) ,
4726+ uses_odbc_syntax: false ,
47194727 parameters: FunctionArguments :: None ,
47204728 args: FunctionArguments :: List ( FunctionArgumentList {
47214729 duplicate_treatment: None ,
@@ -4846,6 +4854,7 @@ fn test_parse_named_window() {
48464854 quote_style: None ,
48474855 span: Span :: empty( ) ,
48484856 } ] ) ,
4857+ uses_odbc_syntax: false ,
48494858 parameters: FunctionArguments :: None ,
48504859 args: FunctionArguments :: List ( FunctionArgumentList {
48514860 duplicate_treatment: None ,
@@ -4880,6 +4889,7 @@ fn test_parse_named_window() {
48804889 quote_style: None ,
48814890 span: Span :: empty( ) ,
48824891 } ] ) ,
4892+ uses_odbc_syntax: false ,
48834893 parameters: FunctionArguments :: None ,
48844894 args: FunctionArguments :: List ( FunctionArgumentList {
48854895 duplicate_treatment: None ,
@@ -9008,6 +9018,7 @@ fn parse_time_functions() {
90089018 let select = verified_only_select ( & sql) ;
90099019 let select_localtime_func_call_ast = Function {
90109020 name : ObjectName ( vec ! [ Ident :: new( func_name) ] ) ,
9021+ uses_odbc_syntax : false ,
90119022 parameters : FunctionArguments :: None ,
90129023 args : FunctionArguments :: List ( FunctionArgumentList {
90139024 duplicate_treatment : None ,
@@ -10021,6 +10032,7 @@ fn parse_call() {
1002110032 assert_eq ! (
1002210033 verified_stmt( "CALL my_procedure('a')" ) ,
1002310034 Statement :: Call ( Function {
10035+ uses_odbc_syntax: false ,
1002410036 parameters: FunctionArguments :: None ,
1002510037 args: FunctionArguments :: List ( FunctionArgumentList {
1002610038 duplicate_treatment: None ,
@@ -10511,6 +10523,7 @@ fn test_selective_aggregation() {
1051110523 vec![
1051210524 SelectItem :: UnnamedExpr ( Expr :: Function ( Function {
1051310525 name: ObjectName ( vec![ Ident :: new( "ARRAY_AGG" ) ] ) ,
10526+ uses_odbc_syntax: false ,
1051410527 parameters: FunctionArguments :: None ,
1051510528 args: FunctionArguments :: List ( FunctionArgumentList {
1051610529 duplicate_treatment: None ,
@@ -10529,6 +10542,7 @@ fn test_selective_aggregation() {
1052910542 SelectItem :: ExprWithAlias {
1053010543 expr: Expr :: Function ( Function {
1053110544 name: ObjectName ( vec![ Ident :: new( "ARRAY_AGG" ) ] ) ,
10545+ uses_odbc_syntax: false ,
1053210546 parameters: FunctionArguments :: None ,
1053310547 args: FunctionArguments :: List ( FunctionArgumentList {
1053410548 duplicate_treatment: None ,
@@ -10966,6 +10980,35 @@ fn insert_into_with_parentheses() {
1096610980 dialects. verified_stmt ( "INSERT INTO t1 (id, name) (SELECT t2.id, t2.name FROM t2)" ) ;
1096710981}
1096810982
10983+ #[ test]
10984+ fn parse_odbc_scalar_function ( ) {
10985+ let select = verified_only_select ( "SELECT {fn my_func(1, 2)}" ) ;
10986+ let Expr :: Function ( Function {
10987+ name,
10988+ uses_odbc_syntax,
10989+ args,
10990+ ..
10991+ } ) = expr_from_projection ( only ( & select. projection ) )
10992+ else {
10993+ unreachable ! ( "expected function" )
10994+ } ;
10995+ assert_eq ! ( name, & ObjectName ( vec![ Ident :: new( "my_func" ) ] ) ) ;
10996+ assert ! ( uses_odbc_syntax) ;
10997+ matches ! ( args, FunctionArguments :: List ( l) if l. args. len( ) == 2 ) ;
10998+
10999+ verified_stmt ( "SELECT {fn fna()} AS foo, fnb(1)" ) ;
11000+
11001+ // Testing invalid SQL with any-one dialect is intentional.
11002+ // Depending on dialect flags the error message may be different.
11003+ let pg = TestedDialects :: new ( vec ! [ Box :: new( PostgreSqlDialect { } ) ] ) ;
11004+ assert_eq ! (
11005+ pg. parse_sql_statements( "SELECT {fn2 my_func()}" )
11006+ . unwrap_err( )
11007+ . to_string( ) ,
11008+ "sql parser error: Expected: an expression, found: {"
11009+ ) ;
11010+ }
11011+
1096911012#[ test]
1097011013fn test_dictionary_syntax ( ) {
1097111014 fn check ( sql : & str , expect : Expr ) {
0 commit comments