Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 4545 Sqlite 3-35 On Conflict #4551

Merged
merged 3 commits into from
Aug 28, 2023
Merged

Conversation

griffio
Copy link
Contributor

@griffio griffio commented Aug 21, 2023

Allow multiple ON CONFLICT clauses that are evaluated in order, The final ON CONFLICT clause may omit the conflict target and yet still use DO UPDATE

fixes #4545

Restrict final ON CONFLICT to have optional conflict target

For example - add a new mix-in to check the new upsertClauseList element to annotate that only the last element is allowed optional conflict target 馃幆

The new InsertStmtMixin copies the 3.24 annotations but must now validate more than one ON CONFLICT clause

insert_stmt ::= [ {with_clause} ]
  ( INSERT OR REPLACE | REPLACE | INSERT OR ROLLBACK | INSERT OR ABORT | INSERT OR FAIL | INSERT OR IGNORE | INSERT )
  INTO [ {database_name} DOT ] {table_name} [ AS {table_alias} ]
  [ LP {column_name} ( COMMA {column_name} ) * RP ] {insert_stmt_values} [ ( upsert_clause ) * ] [ returning_clause ] {
  mixin = "app.cash.sqldelight.dialects.sqlite_3_35.grammar.mixins.InsertStmtMixin"
  pin = 5
  override = true
}

Allow multiple ON CONFLICT clauses that are evaluated in order,
The final ON CONFLICT clause may omit the conflict target and yet still use DO UPDATE

TODO - restrict final ON CONFLICT to have optional conflict target
Multiple ON CONFLICT clauses are allowed in the grammar
Only the final clause allows optional conflict target and annotated in the Mixin

Add fixture test
@griffio griffio marked this pull request as ready for review August 23, 2023 12:07
Similar to sqlite-3-24 test extended for multiple ON CONFLICT clauses
@griffio griffio changed the title sqlite 3-35 On Conflict Fix 4545 Sqlite 3-35 On Conflict Aug 23, 2023
@AlecKazakova AlecKazakova merged commit 71ee973 into cashapp:master Aug 28, 2023
7 checks passed
hfhbd pushed a commit that referenced this pull request Apr 2, 2024
* sqlite 3-35 On Conflict

Allow multiple ON CONFLICT clauses that are evaluated in order,
The final ON CONFLICT clause may omit the conflict target and yet still use DO UPDATE

TODO - restrict final ON CONFLICT to have optional conflict target

* Add InsertStmtMixin

Multiple ON CONFLICT clauses are allowed in the grammar
Only the final clause allows optional conflict target and annotated in the Mixin

Add fixture test

* Add Integration Test

Similar to sqlite-3-24 test extended for multiple ON CONFLICT clauses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow multiple ON CONFLICT clauses that are evaluated in order
2 participants