@@ -1108,6 +1108,7 @@ fn parse_select_count_wildcard() {
1108
1108
assert_eq ! (
1109
1109
& Expr :: Function ( Function {
1110
1110
name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
1111
+ uses_odbc_syntax: false ,
1111
1112
parameters: FunctionArguments :: None ,
1112
1113
args: FunctionArguments :: List ( FunctionArgumentList {
1113
1114
duplicate_treatment: None ,
@@ -1130,6 +1131,7 @@ fn parse_select_count_distinct() {
1130
1131
assert_eq ! (
1131
1132
& Expr :: Function ( Function {
1132
1133
name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
1134
+ uses_odbc_syntax: false ,
1133
1135
parameters: FunctionArguments :: None ,
1134
1136
args: FunctionArguments :: List ( FunctionArgumentList {
1135
1137
duplicate_treatment: Some ( DuplicateTreatment :: Distinct ) ,
@@ -2366,6 +2368,7 @@ fn parse_select_having() {
2366
2368
Some ( Expr :: BinaryOp {
2367
2369
left: Box :: new( Expr :: Function ( Function {
2368
2370
name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
2371
+ uses_odbc_syntax: false ,
2369
2372
parameters: FunctionArguments :: None ,
2370
2373
args: FunctionArguments :: List ( FunctionArgumentList {
2371
2374
duplicate_treatment: None ,
@@ -2396,6 +2399,7 @@ fn parse_select_qualify() {
2396
2399
Some ( Expr :: BinaryOp {
2397
2400
left: Box :: new( Expr :: Function ( Function {
2398
2401
name: ObjectName ( vec![ Ident :: new( "ROW_NUMBER" ) ] ) ,
2402
+ uses_odbc_syntax: false ,
2399
2403
parameters: FunctionArguments :: None ,
2400
2404
args: FunctionArguments :: List ( FunctionArgumentList {
2401
2405
duplicate_treatment: None ,
@@ -2802,6 +2806,7 @@ fn parse_listagg() {
2802
2806
assert_eq ! (
2803
2807
& Expr :: Function ( Function {
2804
2808
name: ObjectName ( vec![ Ident :: new( "LISTAGG" ) ] ) ,
2809
+ uses_odbc_syntax: false ,
2805
2810
parameters: FunctionArguments :: None ,
2806
2811
args: FunctionArguments :: List ( FunctionArgumentList {
2807
2812
duplicate_treatment: Some ( DuplicateTreatment :: Distinct ) ,
@@ -4603,6 +4608,7 @@ fn parse_named_argument_function() {
4603
4608
assert_eq ! (
4604
4609
& Expr :: Function ( Function {
4605
4610
name: ObjectName ( vec![ Ident :: new( "FUN" ) ] ) ,
4611
+ uses_odbc_syntax: false ,
4606
4612
parameters: FunctionArguments :: None ,
4607
4613
args: FunctionArguments :: List ( FunctionArgumentList {
4608
4614
duplicate_treatment: None ,
@@ -4642,6 +4648,7 @@ fn parse_named_argument_function_with_eq_operator() {
4642
4648
assert_eq ! (
4643
4649
& Expr :: Function ( Function {
4644
4650
name: ObjectName ( vec![ Ident :: new( "FUN" ) ] ) ,
4651
+ uses_odbc_syntax: false ,
4645
4652
parameters: FunctionArguments :: None ,
4646
4653
args: FunctionArguments :: List ( FunctionArgumentList {
4647
4654
duplicate_treatment: None ,
@@ -4716,6 +4723,7 @@ fn parse_window_functions() {
4716
4723
assert_eq ! (
4717
4724
& Expr :: Function ( Function {
4718
4725
name: ObjectName ( vec![ Ident :: new( "row_number" ) ] ) ,
4726
+ uses_odbc_syntax: false ,
4719
4727
parameters: FunctionArguments :: None ,
4720
4728
args: FunctionArguments :: List ( FunctionArgumentList {
4721
4729
duplicate_treatment: None ,
@@ -4846,6 +4854,7 @@ fn test_parse_named_window() {
4846
4854
quote_style: None ,
4847
4855
span: Span :: empty( ) ,
4848
4856
} ] ) ,
4857
+ uses_odbc_syntax: false ,
4849
4858
parameters: FunctionArguments :: None ,
4850
4859
args: FunctionArguments :: List ( FunctionArgumentList {
4851
4860
duplicate_treatment: None ,
@@ -4880,6 +4889,7 @@ fn test_parse_named_window() {
4880
4889
quote_style: None ,
4881
4890
span: Span :: empty( ) ,
4882
4891
} ] ) ,
4892
+ uses_odbc_syntax: false ,
4883
4893
parameters: FunctionArguments :: None ,
4884
4894
args: FunctionArguments :: List ( FunctionArgumentList {
4885
4895
duplicate_treatment: None ,
@@ -9008,6 +9018,7 @@ fn parse_time_functions() {
9008
9018
let select = verified_only_select ( & sql) ;
9009
9019
let select_localtime_func_call_ast = Function {
9010
9020
name : ObjectName ( vec ! [ Ident :: new( func_name) ] ) ,
9021
+ uses_odbc_syntax : false ,
9011
9022
parameters : FunctionArguments :: None ,
9012
9023
args : FunctionArguments :: List ( FunctionArgumentList {
9013
9024
duplicate_treatment : None ,
@@ -10021,6 +10032,7 @@ fn parse_call() {
10021
10032
assert_eq ! (
10022
10033
verified_stmt( "CALL my_procedure('a')" ) ,
10023
10034
Statement :: Call ( Function {
10035
+ uses_odbc_syntax: false ,
10024
10036
parameters: FunctionArguments :: None ,
10025
10037
args: FunctionArguments :: List ( FunctionArgumentList {
10026
10038
duplicate_treatment: None ,
@@ -10511,6 +10523,7 @@ fn test_selective_aggregation() {
10511
10523
vec![
10512
10524
SelectItem :: UnnamedExpr ( Expr :: Function ( Function {
10513
10525
name: ObjectName ( vec![ Ident :: new( "ARRAY_AGG" ) ] ) ,
10526
+ uses_odbc_syntax: false ,
10514
10527
parameters: FunctionArguments :: None ,
10515
10528
args: FunctionArguments :: List ( FunctionArgumentList {
10516
10529
duplicate_treatment: None ,
@@ -10529,6 +10542,7 @@ fn test_selective_aggregation() {
10529
10542
SelectItem :: ExprWithAlias {
10530
10543
expr: Expr :: Function ( Function {
10531
10544
name: ObjectName ( vec![ Ident :: new( "ARRAY_AGG" ) ] ) ,
10545
+ uses_odbc_syntax: false ,
10532
10546
parameters: FunctionArguments :: None ,
10533
10547
args: FunctionArguments :: List ( FunctionArgumentList {
10534
10548
duplicate_treatment: None ,
@@ -10968,6 +10982,35 @@ fn insert_into_with_parentheses() {
10968
10982
dialects. verified_stmt ( r#"INSERT INTO t1 ("select", name) (SELECT t2.name FROM t2)"# ) ;
10969
10983
}
10970
10984
10985
+ #[ test]
10986
+ fn parse_odbc_scalar_function ( ) {
10987
+ let select = verified_only_select ( "SELECT {fn my_func(1, 2)}" ) ;
10988
+ let Expr :: Function ( Function {
10989
+ name,
10990
+ uses_odbc_syntax,
10991
+ args,
10992
+ ..
10993
+ } ) = expr_from_projection ( only ( & select. projection ) )
10994
+ else {
10995
+ unreachable ! ( "expected function" )
10996
+ } ;
10997
+ assert_eq ! ( name, & ObjectName ( vec![ Ident :: new( "my_func" ) ] ) ) ;
10998
+ assert ! ( uses_odbc_syntax) ;
10999
+ matches ! ( args, FunctionArguments :: List ( l) if l. args. len( ) == 2 ) ;
11000
+
11001
+ verified_stmt ( "SELECT {fn fna()} AS foo, fnb(1)" ) ;
11002
+
11003
+ // Testing invalid SQL with any-one dialect is intentional.
11004
+ // Depending on dialect flags the error message may be different.
11005
+ let pg = TestedDialects :: new ( vec ! [ Box :: new( PostgreSqlDialect { } ) ] ) ;
11006
+ assert_eq ! (
11007
+ pg. parse_sql_statements( "SELECT {fn2 my_func()}" )
11008
+ . unwrap_err( )
11009
+ . to_string( ) ,
11010
+ "sql parser error: Expected: an expression, found: {"
11011
+ ) ;
11012
+ }
11013
+
10971
11014
#[ test]
10972
11015
fn test_dictionary_syntax ( ) {
10973
11016
fn check ( sql : & str , expect : Expr ) {
0 commit comments