Skip to content

Conversation

@JanJakes
Copy link
Member

@JanJakes JanJakes commented Jan 7, 2026

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:

  1. UPSERT / ON CONFLICT clause (SQLite < 3.35.0) — The generic ON CONFLICT DO UPDATE clause 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.

  2. STRICT tables (SQLite < 3.37.0) — The STRICT keyword for table creation is only supported from SQLite 3.37.0. It is now conditionally omitted on older versions.

  3. VALUES list columnN naming (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 dummy SELECT NULL AS column1, ... WHERE FALSE UNION ALL ... header.

  4. UPDATE ... FROM syntax (SQLite < 3.33.0) — The UPDATE ... FROM syntax is only supported from SQLite 3.33.0. We now avoid using it internally in the information schema builder.

  5. IIF() function (all versions) — The IIF() function was added in SQLite 3.32.0. We now use CASE WHEN ... THEN ... ELSE ... END instead for broader compatibility.

  6. SUBSTRING() function (all versions) — The SUBSTRING() function is not supported in older SQLite versions. We now translate it to SUBSTR().

  7. sqlite_schema table (SQLite < 3.33.0) — The sqlite_schema table alias was added in SQLite 3.33.0. We now use the older sqlite_master name for compatibility.

  8. SQLite version detection — Changed from using a SELECT SQLITE_VERSION() query to using the PDO::ATTR_SERVER_VERSION attribute for retrieving the SQLite version, which avoids extra queries by using SQLite C API directly.

  9. CI workflow — Added support for testing against multiple SQLite versions.

@JanJakes JanJakes force-pushed the on-conflict-clause-legacy-fix branch 20 times, most recently from ae3a212 to a713a67 Compare January 7, 2026 16:40
@JanJakes JanJakes force-pushed the on-conflict-clause-legacy-fix branch 9 times, most recently from 53d0133 to 3932f95 Compare January 9, 2026 08:17
@JanJakes JanJakes force-pushed the on-conflict-clause-legacy-fix branch 2 times, most recently from 040e014 to a2398a3 Compare January 9, 2026 13:52
@JanJakes JanJakes force-pushed the on-conflict-clause-legacy-fix branch 2 times, most recently from 36a0880 to 2576a15 Compare January 9, 2026 15:25
@JanJakes JanJakes changed the title WIP Fix UPSERT (ON CONFLICT clause) on SQLite < 3.35.0 Improve compatibility with legacy SQLite versions Jan 9, 2026
@JanJakes JanJakes force-pushed the on-conflict-clause-legacy-fix branch 4 times, most recently from 570a5a0 to 815aa76 Compare January 9, 2026 16:05
@JanJakes JanJakes force-pushed the on-conflict-clause-legacy-fix branch from 815aa76 to 3bb586b Compare January 12, 2026 09:39
@JanJakes JanJakes force-pushed the on-conflict-clause-legacy-fix branch from 3bb586b to 7e14b6e Compare January 12, 2026 09:47
@JanJakes JanJakes requested a review from a team January 12, 2026 10:34
@JanJakes JanJakes marked this pull request as ready for review January 12, 2026 10:34
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.

2 participants