-
Notifications
You must be signed in to change notification settings - Fork 54
Improve compatibility with legacy SQLite versions #302
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ae3a212 to
a713a67
Compare
53d0133 to
3932f95
Compare
36a0880 to
2576a15
Compare
ON CONFLICT clause) on SQLite < 3.35.0570a5a0 to
815aa76
Compare
815aa76 to
3bb586b
Compare
…h SQLite < 3.33.0
…upport on old SQLite versions
3bb586b to
7e14b6e
Compare
|
I didn't test each case individually, but I tested the changes on the Studio and Studio preview sites. It worked well in all cases. Code-wise looks good. It's great that we are adding support for older SQLite versions, as it will improve support on some LTS images. |
| rowid, | ||
| row_number() OVER (PARTITION BY index_name ORDER BY seq_in_index) AS seq_in_index | ||
| FROM %s | ||
| FROM %s x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this x is a leftover from a quick fix when I was probably nagged by SQLite to use an alias. I'll rename it to something more reasonable, in case it is required.
SQLite Version Compatibility Fixes
This PR adds support for older SQLite versions by addressing various compatibility issues. It also updates the CI workflow to test against multiple SQLite versions.
Compatibility fixes:
UPSERT / ON CONFLICT clause (SQLite < 3.35.0) — The generic
ON CONFLICT DO UPDATEclause without an explicit column list is only supported from SQLite 3.35.0. For older versions, we now catch the constraint violation error, parse the conflicting column names from the error message, and re-execute with an explicit column list.STRICT tables (SQLite < 3.37.0) — The
STRICTkeyword for table creation is only supported from SQLite 3.37.0. It is now conditionally omitted on older versions.VALUES list
columnNnaming (SQLite < 3.33.0) — Automatic column naming for VALUES lists (column1,column2, etc.) is only supported from SQLite 3.33.0. For older versions, we now emulate this by prepending a dummySELECT NULL AS column1, ... WHERE FALSE UNION ALL ...header.UPDATE ... FROMsyntax (SQLite < 3.33.0) — TheUPDATE ... FROMsyntax is only supported from SQLite 3.33.0. We now avoid using it internally in the information schema builder.IIF()function (all versions) — TheIIF()function was added in SQLite 3.32.0. We now useCASE WHEN ... THEN ... ELSE ... ENDinstead for broader compatibility.SUBSTRING()function (all versions) — TheSUBSTRING()function is not supported in older SQLite versions. We now translate it toSUBSTR().sqlite_schematable (SQLite < 3.33.0) — Thesqlite_schematable alias was added in SQLite 3.33.0. We now use the oldersqlite_mastername for compatibility.SQLite version detection — Changed from using a
SELECT SQLITE_VERSION()query to using thePDO::ATTR_SERVER_VERSIONattribute for retrieving the SQLite version, which avoids extra queries by using SQLite C API directly.CI workflow — Added support for testing against multiple SQLite versions.