Repository navigation
feat: parse UPDATE OR conflict algorithms in the SQLite dialect - #2885
Open
DylanMerigaud wants to merge 1 commit into
Open
DylanMerigaud wants to merge 1 commit into
DylanMerigaud wants to merge 1 commit into
Conversation
SQLite accepts ABORT, FAIL, IGNORE, REPLACE and ROLLBACK after UPDATE OR. Update gets a conflictAlgorithm (UpdateConflictAlgorithm), printed by toString() and UpdateDeParser. The grammar reads the word with RelObjectName and AbstractJSqlParser.updateOrAlgorithm decides it, as INSERT OR does. UPDATE OR needs Dialect.SQLITE. Part of JSQLParser#2852
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2852 (the
UPDATE ORpart;WITHOUT ROWIDandSTRICTare not in this PR).INSERT OR REPLACEalready parsed, and #2853 addedINSERT OR ABORT,FAIL,IGNOREandROLLBACK. SQLite takes the same five conflict algorithms afterUPDATE OR(lang_update), and the issue's table showsUPDATE OR IGNORE t SET a = 1andUPDATE OR REPLACE t SET a = 1stopping atEncountered: <K_UPDATE> / "UPDATE".What changes:
UpdateConflictAlgorithm(ABORT,FAIL,IGNORE,REPLACE,ROLLBACK), next toUpdateModifierPriority.UpdategetsgetConflictAlgorithm(),setConflictAlgorithm()andwithConflictAlgorithm(). The value isnullfor anUPDATEwithoutOR, so existing statements build the same object.Update.toString()andUpdateDeParserprintOR <algorithm>right afterUPDATE.Updateproduction reads[ <K_OR> RelObjectName() ]afterUPDATE, andAbstractJSqlParser.updateOrAlgorithmmaps the word to the enum. This is the shape feat: parse INSERT OR ABORT, FAIL, IGNORE and ROLLBACK (SQLite) #2853 settled on forINSERT OR, which keeps the addition toCCJSqlParserto one optional (the constant-pool headroom of JaCoCo instrumentation of CCJSqlParser is approaching the constant-pool limit #2866).UPDATE ORneedsDialect.SQLITE. Without it, or with a word that is not one of the five, the statement is a parse error.usage.rstlistsUPDATE ORin theSQLITErow of the dialect table.Tests, all in
SQLiteTest:testUpdateOrConflictAlgorithm, one case per algorithm: parse and round trip throughtoString()and the deparser, in upper and lower case, andgetConflictAlgorithm()returns that algorithm.testUpdateOrConflictAlgorithmNeedsSqliteDialect, one case per algorithm: rejected without the dialect.testUpdateOrUnknownAlgorithm:UPDATE OR NOTHINGis rejected with the dialect.testUpdateWithoutConflictAlgorithm: a plainUPDATEkeepsgetConflictAlgorithm()null.The two rejection tests would also pass on a parser with no
UPDATE ORsupport at all; a comment above each says so. They pin the dialect guard and the word check.