File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -3774,7 +3774,12 @@ impl<'a> Parser<'a> {
37743774 } ) ;
37753775 }
37763776
3777- let variable = self . parse_object_name ( ) ?;
3777+ let variable = if self . parse_keywords ( & vec ! [ Keyword :: TIME , Keyword :: ZONE ] ) {
3778+ ObjectName ( vec ! [ "TIMEZONE" . into( ) ] )
3779+ } else {
3780+ self . parse_object_name ( ) ?
3781+ } ;
3782+
37783783 if variable. to_string ( ) . eq_ignore_ascii_case ( "NAMES" )
37793784 && dialect_of ! ( self is MySqlDialect | GenericDialect )
37803785 {
Original file line number Diff line number Diff line change @@ -4663,6 +4663,49 @@ fn parse_set_transaction() {
46634663 }
46644664}
46654665
4666+ #[ test]
4667+ fn parse_set_variable ( ) {
4668+ match verified_stmt ( "SET SOMETHING = 1" ) {
4669+ Statement :: SetVariable {
4670+ local,
4671+ hivevar,
4672+ variable,
4673+ value,
4674+ } => {
4675+ assert ! ( !local) ;
4676+ assert ! ( !hivevar) ;
4677+ assert_eq ! ( variable, ObjectName ( vec![ "SOMETHING" . into( ) ] ) ) ;
4678+ assert_eq ! ( value, vec![ Expr :: Value ( Value :: Number ( "1" . into( ) , false ) ) ] ) ;
4679+ }
4680+ _ => unreachable ! ( ) ,
4681+ }
4682+
4683+ one_statement_parses_to ( "SET SOMETHING TO 1" , "SET SOMETHING = 1" ) ;
4684+ }
4685+
4686+ #[ test]
4687+ fn parse_set_time_zone ( ) {
4688+ match verified_stmt ( "SET TIMEZONE = 'UTC'" ) {
4689+ Statement :: SetVariable {
4690+ local,
4691+ hivevar,
4692+ variable,
4693+ value,
4694+ } => {
4695+ assert ! ( !local) ;
4696+ assert ! ( !hivevar) ;
4697+ assert_eq ! ( variable, ObjectName ( vec![ "TIMEZONE" . into( ) ] ) ) ;
4698+ assert_eq ! (
4699+ value,
4700+ vec![ Expr :: Value ( Value :: SingleQuotedString ( "UTC" . into( ) ) ) ]
4701+ ) ;
4702+ }
4703+ _ => unreachable ! ( ) ,
4704+ }
4705+
4706+ one_statement_parses_to ( "SET TIME ZONE TO 'UTC'" , "SET TIMEZONE = 'UTC'" ) ;
4707+ }
4708+
46664709#[ test]
46674710fn parse_commit ( ) {
46684711 match verified_stmt ( "COMMIT" ) {
You can’t perform that action at this time.
0 commit comments