fix(sqlite): support INSERT IGNORE and offset-only limits [CODEX]#7674
Merged
georgesittas merged 5 commits intoMay 27, 2026
Merged
Conversation
Collaborator
georgesittas
left a comment
There was a problem hiding this comment.
Thank you for the PR!
Comment on lines
+215
to
+218
| if expression.args.get("ignore"): | ||
| expression.set("ignore", False) | ||
| expression.set("alternative", "IGNORE") | ||
|
|
Collaborator
There was a problem hiding this comment.
Hmm... this is fine for now, but looks like a code smell to me. Having two ways to represent the IGNORE semantics doesn't look right. Perhaps something to clean up in the future...
Contributor
Author
There was a problem hiding this comment.
good catch here. let me think about a better way to do this
Collaborator
There was a problem hiding this comment.
This is fine for now, let's not deal with it in this PR. Just wanted to leave a note for future reference.
Contributor
Author
|
All feedback addressed, thanks. Should have checked tests a little more thoroughly |
georgesittas
approved these changes
May 27, 2026
georgesittas
added a commit
that referenced
this pull request
May 27, 2026
…7674) * Fix SQLite output for ignore and offset limits * Address SQLite limit review feedback * Scope LIMIT ALL parsing to supporting dialects * Address LIMIT ALL review feedback * Update tests/dialects/test_dialect.py --------- Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>
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.
Summary
Fix SQLite-targeted transpilation for three cases that currently produce SQL SQLite rejects:
INSERT IGNORE ...-> SQLiteINSERT OR IGNORE ...LIMIT ALL-> no SQLiteLIMITclauseOFFSET n-> SQLiteLIMIT -1 OFFSET nThese are represented directly in SQLite syntax rather than unsupported semantics.
Examples
I also checked the combined case:
Why
SQLite uses
INSERT OR IGNOREfor this conflict behavior, not MySQL'sINSERT IGNORE. SQLite's INSERT docs describe theINSERT OR actionform for choosing a constraint conflict algorithm: https://www.sqlite.org/lang_insert.htmlSQLite also requires
OFFSETto appear as part of aLIMITclause;LIMIT -1 OFFSET nis the common SQLite spelling for offset without an upper row bound. Related prior art/background on emulating MySQL conflict behavior in other dialects: https://stackoverflow.com/questions/1009584/how-to-emulate-insert-ignore-and-on-duplicate-key-update-sql-merge-with-poI searched for existing SQLGlot issues/PRs mentioning these exact SQLite-target gaps and did not find an existing report.
Tests
python3 -m unittest tests.dialects.test_sqlite.TestSQLite.test_sqlitepython3 -m unittest tests.dialects.test_dialect.TestDialect.test_limit tests.dialects.test_mysql.TestMySQL.test_mysqlpython3 -m unittest tests.dialects.test_sqlitepython3 -m ruff check sqlglot/generators/sqlite.py tests/dialects/test_sqlite.pygit diff --check