Skip to content

fix: classify PG18 RESTRICT (23001) as ForeignKeyViolationError - #338

Open
0x054 wants to merge 3 commits into
mainfrom
fix/336-integrity-code-table
Open

fix: classify PG18 RESTRICT (23001) as ForeignKeyViolationError#338
0x054 wants to merge 3 commits into
mainfrom
fix/336-integrity-code-table

Conversation

@0x054

@0x054 0x054 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Deleting a parent still referenced by ForeignKey(on_delete="RESTRICT") now raises ForeignKeyViolationError on PostgreSQL 18, same as 17. PG18 reports SQLSTATE 23001 (restrict_violation); sqlx kind() still treats that as Other.
  • Ferro owns the integrity-code table (23001 / 23503 / SQLite 1811 → FK). sqlstate stays the raw driver code. Catch the type, not a code or a message.
  • Live pins on instance.delete() and Query.delete(). Solutions note: docs/solutions/issues/pg18-restrict-sqlstate-23001.md.

Closes #306
Fixes #336
Fixes #337

Test plan

Made with Cursor

0x054 and others added 3 commits August 15, 2026 15:14
Postgres 18 reports ON DELETE/UPDATE RESTRICT as 23001; sqlx kind()
still treats that as Other. Ferro now owns the integrity-code table
so RESTRICT raises ForeignKeyViolationError on every major.

Refs #336

Co-authored-by: Cursor <cursoragent@cursor.com>
Live instance and query deletes under on_delete=RESTRICT now assert
the typed exception. SQLite reports that path as 1811 (trigger), so
the integrity-code table maps it the same way as PG18 23001.

Refs #337

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant