Repository navigation
feat: parse INSERT OR ABORT, FAIL, IGNORE and ROLLBACK (SQLite) - #2853
manticore-projects merged 3 commits into
Conversation
| ( | ||
| <K_INSERT> <K_OR> <K_REPLACE> { upsert.setUpsertType(UpsertType.INSERT_OR_REPLACE); } | ||
| <K_INSERT> <K_OR> | ||
| ( |
There was a problem hiding this comment.
I do understand that this is SQLite specific syntax. If my understanding is correct, then please guard this block by the SQLite Dialect.
There was a problem hiding this comment.
Thanks, done in 8805d37. There was no SQLite value in Dialect, so I added Dialect.SQLITE and listed it in the dialect table in usage.rst.
INSERT OR IGNORE, ROLLBACK, ABORT and FAIL now parse only with Dialect.SQLITE; other dialects get a ParseException saying so. INSERT OR REPLACE still parses everywhere, because it did before this PR. The tests cover both cases, and the checks are green.
589893e to
8805d37
Compare
|
Please fix the failing QA/CI tests. |
8805d37 to
fe5d183
Compare
UpsertType and the deparsers already had these values, but the grammar only accepted INSERT OR REPLACE. Part of JSQLParser#2852
Add Dialect.SQLITE. INSERT OR ABORT, FAIL, IGNORE and ROLLBACK need it. INSERT OR REPLACE keeps parsing in every dialect.
fe5d183 to
7eb65c8
Compare
The extra INSERT OR alternatives pushed the constant pool of CCJSqlParser past 65535 entries once JaCoCo instrumented it, so the class was silently left without coverage data and the coverage check failed. Parse the algorithm with RelObjectName and decide in AbstractJSqlParser instead.
|
The CI failure was a JaCoCo issue, not a test failure. 7ffb392 parses the algorithm with |
|
Thank you much! |
Part of #2852 (the
INSERT ORhalf;UPDATE OR ...,WITHOUT ROWIDandSTRICTare not in this PR).UpsertTypealready hasINSERT_OR_ABORT,INSERT_OR_FAIL,INSERT_OR_IGNOREandINSERT_OR_ROLLBACK, andUpsertandUpsertDeParserprint them, but the grammar only acceptedINSERT OR REPLACE. This adds the other four to theUpsertproduction.ABORTandFAILare not keywords of the parser, so they are read as identifiers and checked by name; any other word afterINSERT ORis a parse error.SQLiteTestcovers all five algorithms with column list andSELECTsource, a lower case variant, and an unknown word. The four new cases fail without the grammar change. The full./gradlew testrun has 35 failures (StatementDeParserTest, ExpressionDeParserTest, WithFunctionDeclarationTest and others); they fail the same way on an unmodifiedmasterhere (JDK 25), none involve INSERT OR.