File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -4759,7 +4759,14 @@ impl<'a> Parser<'a> {
47594759 Token :: HexStringLiteral ( ref s) => Ok ( Value :: HexStringLiteral ( s. to_string ( ) ) ) ,
47604760 Token :: Placeholder ( ref s) => Ok ( Value :: Placeholder ( s. to_string ( ) ) ) ,
47614761 tok @ Token :: Colon | tok @ Token :: AtSign => {
4762- let ident = self . parse_identifier ( ) ?;
4762+ // Not calling self.parse_identifier()? because only in placeholder we want to check numbers as idfentifies
4763+ // This because snowflake allows numbers as placeholders
4764+ let next_token = self . next_token ( ) ;
4765+ let ident = match next_token. token {
4766+ Token :: Word ( w) => Ok ( w. to_ident ( ) ) ,
4767+ Token :: Number ( w, false ) => Ok ( Ident :: new ( w) ) ,
4768+ _ => self . expected ( "placeholder" , next_token) ,
4769+ } ?;
47634770 let placeholder = tok. to_string ( ) + & ident. value ;
47644771 Ok ( Value :: Placeholder ( placeholder) )
47654772 }
Original file line number Diff line number Diff line change @@ -1079,6 +1079,20 @@ fn test_snowflake_trim() {
10791079 ) ;
10801080}
10811081
1082+ #[ test]
1083+ fn test_number_placeholder ( ) {
1084+ let sql_only_select = "SELECT :1" ;
1085+ let select = snowflake ( ) . verified_only_select ( sql_only_select) ;
1086+ assert_eq ! (
1087+ & Expr :: Value ( Value :: Placeholder ( ":1" . into( ) ) ) ,
1088+ expr_from_projection( only( & select. projection) )
1089+ ) ;
1090+
1091+ snowflake ( )
1092+ . parse_sql_statements ( "alter role 1 with name = 'foo'" )
1093+ . expect_err ( "should have failed" ) ;
1094+ }
1095+
10821096#[ test]
10831097fn parse_position_not_function_columns ( ) {
10841098 snowflake_and_generic ( )
You can’t perform that action at this time.
0 commit comments