New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add set time zone sometimezone as a exception while parsing keyword::set #727
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4573,6 +4573,15 @@ impl<'a> Parser<'a> { | |
value: values, | ||
}); | ||
} | ||
} else if variable.to_string().eq_ignore_ascii_case("TIMEZONE") { | ||
// for some db (e.g. postgresql), SET TIME ZONE <value> is an alias for SET TIMEZONE [TO|=] <value> | ||
match self.parse_expr() { | ||
Ok(expr) => Ok(Statement::SetTimeZone { | ||
local: modifier == Some(Keyword::LOCAL), | ||
value: expr, | ||
}), | ||
_ => self.expected("timezone value", self.peek_token())?, | ||
} | ||
Comment on lines
+4576
to
+4584
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this captures the |
||
} else if variable.to_string() == "CHARACTERISTICS" { | ||
self.expect_keywords(&[Keyword::AS, Keyword::TRANSACTION])?; | ||
Ok(Statement::SetTransaction { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4979,6 +4979,19 @@ fn parse_set_time_zone() { | |
one_statement_parses_to("SET TIME ZONE TO 'UTC'", "SET TIMEZONE = 'UTC'"); | ||
} | ||
|
||
#[test] | ||
fn parse_set_time_zone_alias() { | ||
println!("wew"); | ||
match verified_stmt("SET TIME ZONE 'UTC'") { | ||
Statement::SetTimeZone { local, value } => { | ||
assert!(!local); | ||
println!("wew"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated, thank you @alamb |
||
assert_eq!(value, Expr::Value(Value::SingleQuotedString("UTC".into()))); | ||
} | ||
_ => unreachable!(), | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a test case for |
||
|
||
#[test] | ||
fn parse_commit() { | ||
match verified_stmt("COMMIT") { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a new Statement SetTimeZone to reflect the difference between
SET TIME ZONE TO 'UTC'
andSET TIME ZONE 'UTC'