-
Notifications
You must be signed in to change notification settings - Fork 560
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
Support UPDATE ... FROM ( subquery )
in some dialects
#694
Conversation
src/parser.rs
Outdated
@@ -5075,7 +5075,9 @@ impl<'a> Parser<'a> { | |||
let table = self.parse_table_and_joins()?; | |||
self.expect_keyword(Keyword::SET)?; | |||
let assignments = self.parse_comma_separated(Parser::parse_assignment)?; | |||
let from = if self.parse_keyword(Keyword::FROM) && dialect_of!(self is PostgreSqlDialect) { | |||
let from = if self.parse_keyword(Keyword::FROM) | |||
&& dialect_of!(self is PostgreSqlDialect | BigQueryDialect | SnowflakeDialect | RedshiftSqlDialect | MsSqlDialect) |
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.
@unvalley please add the GenericDialect
as well
fn parse_update_set_from() { | ||
let sql = "UPDATE t1 SET name = t2.name FROM (SELECT name, id FROM t1 GROUP BY id) AS t2 WHERE t1.id = t2.id"; | ||
let dialects = TestedDialects { | ||
dialects: vec![ |
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.
And add the generic dialect on tests as well please
@AugustoFKL Thank you for reviewing. I added GenericDialect to parse and test target. |
Box::new(PostgreSqlDialect {}), | ||
Box::new(BigQueryDialect {}), | ||
Box::new(RedshiftSqlDialect {}), | ||
Box::new(MsSqlDialect {}), |
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.
@unvalley sorry I missed this, I think Snowflake
is missing in tests, isn't it?
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.
It's my fault. Thank you for checking!
I added Snowflake
in 413195b .
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.
LGTM :)
Thanks for the quick response
Pull Request Test Coverage Report for Build 3448066476
💛 - Coveralls |
I took the liberty of merging this PR to the master branch and resolving the conflicts (from #666). Sadly it did not quite make the 0.27 release |
"UPDATE-FROM is supported beginning in SQLite version 3.33.0 (2020-08-14)." from https://www.sqlite.org/lang_update.html
Closes #534
Apply
UPDATE .. FROM (subquery)
for