Repository navigation
Conversation
Generated-by: OpenAI Codex
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3079 +/- ##
=======================================
Coverage 83.64% 83.65%
=======================================
Files 42 42
Lines 35833 35836 +3
Branches 35833 35836 +3
=======================================
+ Hits 29974 29977 +3
Misses 2418 2418
Partials 3441 3441 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
LucaCappelletti94
left a comment
There was a problem hiding this comment.
Reserving ON in keywords lets is_select_item_alias reject it for every dialect that uses the default list.
Keyword::RETURNING,
Keyword::VALUES,
+ Keyword::ON,
// Reserved only as a column alias in the `SELECT` clauseThen, SQLite overrides is_column_alias with its own list, so it needs the same entry to keep INSERT INTO t SELECT 1 ON CONFLICT DO NOTHING parsing.
| Keyword::RETURNING
| Keyword::VALUES
+ | Keyword::ON
| Keyword::FROM| if !explicit && kw == &Keyword::ON && parser.peek_keyword(Keyword::CONFLICT) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
You could drop this lookahead and reserve ON as an implicit column alias instead. Special-casing ON CONFLICT leaves the same failure for MySQL, where INSERT INTO t SELECT 1 ON DUPLICATE KEY UPDATE a = 1 still fails on this branch with Expected: end of statement, found: DUPLICATE although MySQL 8.4 runs it. PostgreSQL 17, SQLite 3.51 and MySQL 8.4 all reject SELECT 1 ON, and with the reservation every existing test still passes.
| if !explicit && kw == &Keyword::ON && parser.peek_keyword(Keyword::CONFLICT) { | |
| return false; | |
| } |
| let generic = TestedDialects::new(vec![Box::new(GenericDialect {})]); | ||
| generic.one_statement_parses_to("SELECT 1 ON", "SELECT 1 AS ON"); |
There was a problem hiding this comment.
You could replace the SELECT 1 ON pin with the MySQL statement. The pin asserts an alias that all three engines reject, and the MySQL statement fails without the reservation.
| let generic = TestedDialects::new(vec![Box::new(GenericDialect {})]); | |
| generic.one_statement_parses_to("SELECT 1 ON", "SELECT 1 AS ON"); | |
| let mysql_and_generic = | |
| TestedDialects::new(vec![Box::new(MySqlDialect {}), Box::new(GenericDialect {})]); | |
| mysql_and_generic.verified_stmt("INSERT INTO t SELECT 1 ON DUPLICATE KEY UPDATE a = 1"); |
Suggested-by: LucaCappelletti94 Generated-by: OpenAI Codex
|
Thanks, @LucaCappelletti94 ! |
Fixes #1987.
The parser treated
ONas an implicit alias for1and then failed atCONFLICTorDUPLICATE. ReserveONin the default and SQLite column-alias lists so theINSERTparser can read both clauses. Explicit aliases still work.The regression tests cover PostgreSQL, Generic, SQLite, and MySQL. PostgreSQL
INSERTsyntaxI used Codex to investigate the bug and draft the fix, regression tests, and PR description.