sqlite-utils/docs
Simon Willison 16bbfb582d add_foreign_keys() errors instead of silently dropping action changes
The existing-foreign-key dedup compared only columns and other_table, so
requesting an FK that already exists with different ON DELETE/ON UPDATE
actions was a silent no-op - and with add_foreign_key() raising "already
exists", there was no signal that the requested actions were dropped.
An exact match (including actions) is still skipped for idempotency;
a mismatch now raises AlterError pointing at table.transform().

Also validates that compound foreign keys passed as 4-tuples have the
same number of columns on both sides - extra other-columns were being
silently discarded, e.g. ("t", ("a",), "other", ("a", "b")) created a
single-column key referencing just "a".

Refs https://github.com/simonw/sqlite-utils/issues/769#issuecomment-4900034150

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 21:53:48 -07:00
..
_static/js Removed trogon feature in favor of sqlite-util-tui 2025-01-10 17:15:02 -08:00
_templates Reformatted CLI examples in docs 2023-05-21 13:57:22 -07:00
.gitignore Initial project layout + database table creation tools 2018-07-28 06:46:17 -07:00
changelog.rst add_foreign_keys() errors instead of silently dropping action changes 2026-07-06 21:53:48 -07:00
cli-reference.rst JSON output no longer escapes non-ASCII characters, new --ascii option (#777) 2026-07-06 11:10:07 -07:00
cli.rst insert/upsert --csv no longer rewrites column types of existing tables 2026-07-06 21:44:56 -07:00
codespell-ignore-words.txt Run codespell against source code too, refs #307 2021-08-03 10:06:08 -07:00
conf.py Fix for frustrating error in 'just docs' locally 2026-07-05 23:19:40 -07:00
contributing.rst dependency-groups.dev and uv in docs (#691) 2025-12-11 15:32:00 -08:00
index.rst Add upgrading guide to the documentation 2026-07-04 19:21:34 +00:00
installation.rst Remove sqlean.py support (#772) 2026-07-05 16:00:52 -07:00
Makefile Add reference page to documentation using Sphinx autodoc (#312) 2021-08-10 16:09:28 -07:00
migrations.rst migrate --stop-before an already-applied migration is now an error 2026-07-06 21:50:05 -07:00
plugins.rst Unwrap hard-wrapped prose in the documentation 2026-07-04 23:33:48 +00:00
python-api.rst add_foreign_keys() errors instead of silently dropping action changes 2026-07-06 21:53:48 -07:00
reference.rst Documentation for compound foreign key support, refs #594 2026-07-05 14:45:08 -07:00
tutorial.ipynb Use double quotes not braces for tables and columns (#678) 2025-11-23 20:43:26 -08:00
upgrading.rst ForeignKey is now a frozen dataclass, restoring hashability 2026-07-06 21:35:45 -07:00