Skip to content

Detect upsert support on SQLite 3.24 to 3.34 - #977

Merged
simonw merged 1 commit into
mainfrom
fix-supports-on-conflict-976
Nov 30, 2026
Merged

simonw merged 1 commit into
mainfrom
fix-supports-on-conflict-976

Conversation

@simonw

@simonw simonw commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Closes #976

Claude Opus 5.5

Database.supports_on_conflict probed with ON CONFLICT DO UPDATE and no conflict target, which SQLite only accepts from 3.35. On 3.24–3.34 the probe failed, so upserts fell back to INSERT OR IGNORE + UPDATE, which silently drops new rows that violate a NOT NULL constraint. The probe now uses on conflict(id) do update ....

Verified against SQLite 3.25.3 in Docker: before the fix supports_on_conflict was False and the example upsert wrote nothing; after, it is True and raises IntegrityError. Full test suite passes there.

Also:

  • Adds SQLite 3.25.3 to the test-sqlite-support.yml matrix (no fallback download URL, so it depends on sqlite.org)
  • New test_supports_on_conflict_matches_sqlite_version test
  • test_fts_triggers_keep_updates_and_deletes_in_sync worked around an FTS5 table-name quoting bug only below 3.24; it actually persists until 3.30.0 (3.29.0 fails, 3.30.1 works), so the cutoff is moved

🤖 Generated with Claude Code


📚 Documentation preview 📚: https://sqlite-utils--977.org.readthedocs.build/en/977/

The supports_on_conflict probe used ON CONFLICT DO UPDATE with no conflict
target, which SQLite only accepts from 3.35. On 3.24-3.34 this fell back to
INSERT OR IGNORE + UPDATE, silently dropping new rows that violated NOT NULL.
The probe now includes an explicit conflict target.

Also adds SQLite 3.25.3 to the CI matrix, and moves the FTS5 quoting
workaround in a test to apply below 3.30.0, where that SQLite bug was fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.82%. Comparing base (cd69c76) to head (59c89fa).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #977   +/-   ##
=======================================
  Coverage   94.82%   94.82%           
=======================================
  Files          10       10           
  Lines        4603     4603           
=======================================
  Hits         4365     4365           
  Misses        238      238           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@simonw
simonw merged commit 74c0b6c into main Nov 30, 2026
85 checks passed
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.

Database.supports_on_conflict bug on SQLite 3.24–3.34

1 participant