File tree Expand file tree Collapse file tree 3 files changed +16
-13
lines changed
Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -11679,18 +11679,14 @@ impl<'a> Parser<'a> {
1167911679 pub fn parse_update(&mut self) -> Result<Statement, ParserError> {
1168011680 let or = self.parse_conflict_clause();
1168111681 let table = self.parse_table_and_joins()?;
11682- let from_before_set = if self.parse_keyword(Keyword::FROM)
11683- && dialect_of!(self is GenericDialect | PostgreSqlDialect | DuckDbDialect | BigQueryDialect | SnowflakeDialect | RedshiftSqlDialect | MsSqlDialect | SQLiteDialect )
11684- {
11682+ let from_before_set = if self.parse_keyword(Keyword::FROM) {
1168511683 Some(self.parse_table_and_joins()?)
1168611684 } else {
1168711685 None
1168811686 };
1168911687 self.expect_keyword(Keyword::SET)?;
1169011688 let assignments = self.parse_comma_separated(Parser::parse_assignment)?;
11691- let from = if self.parse_keyword(Keyword::FROM)
11692- && dialect_of!(self is GenericDialect | PostgreSqlDialect | DuckDbDialect | BigQueryDialect | SnowflakeDialect | RedshiftSqlDialect | MsSqlDialect | SQLiteDialect )
11693- {
11689+ let from = if from_before_set.is_none() && self.parse_keyword(Keyword::FROM) {
1169411690 Some(self.parse_table_and_joins()?)
1169511691 } else {
1169611692 from_before_set
Original file line number Diff line number Diff line change @@ -12396,3 +12396,17 @@ fn test_table_sample() {
1239612396 dialects. verified_stmt ( "SELECT * FROM tbl AS t TABLESAMPLE SYSTEM (50)" ) ;
1239712397 dialects. verified_stmt ( "SELECT * FROM tbl AS t TABLESAMPLE SYSTEM (50) REPEATABLE (10)" ) ;
1239812398}
12399+
12400+ #[ test]
12401+ fn parse_update_from_before_select ( ) {
12402+ let res = all_dialects ( )
12403+ . parse_sql_statements ( "UPDATE t1 FROM (SELECT name, id FROM t1 GROUP BY id) AS t2 SET name = t2.name WHERE t1.id = t2.id" ) ;
12404+
12405+ assert ! ( res. is_ok( ) , "{res:?}" ) ;
12406+
12407+ let res = all_dialects ( ) . parse_sql_statements (
12408+ "UPDATE t1 FROM (SELECT name, id FROM t1 GROUP BY id) AS t2 SET name = t2.name FROM (SELECT name from t2) AS t2" ,
12409+ ) ;
12410+
12411+ assert ! ( res. is_err( ) ) ;
12412+ }
Original file line number Diff line number Diff line change @@ -2974,10 +2974,3 @@ fn test_table_sample() {
29742974 snowflake_and_generic ( ) . verified_stmt ( "SELECT id FROM mytable TABLESAMPLE (10) REPEATABLE (1)" ) ;
29752975 snowflake_and_generic ( ) . verified_stmt ( "SELECT id FROM mytable TABLESAMPLE (10) SEED (1)" ) ;
29762976}
2977-
2978- #[ test]
2979- fn parse_update_from_before_select ( ) {
2980- assert ! ( snowflake( )
2981- . parse_sql_statements( "UPDATE t1 FROM (SELECT name, id FROM t1 GROUP BY id) AS t2 SET name = t2.name WHERE t1.id = t2.id" )
2982- . is_ok( ) ) ;
2983- }
You can’t perform that action at this time.
0 commit comments