fix: classify PG18 RESTRICT (23001) as ForeignKeyViolationError - #338
Open
0x054 wants to merge 3 commits into
Open
fix: classify PG18 RESTRICT (23001) as ForeignKeyViolationError#3380x054 wants to merge 3 commits into
0x054 wants to merge 3 commits into
Conversation
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>
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ForeignKey(on_delete="RESTRICT")now raisesForeignKeyViolationErroron PostgreSQL 18, same as 17. PG18 reports SQLSTATE23001(restrict_violation); sqlxkind()still treats that asOther.23001/23503/ SQLite1811→ FK).sqlstatestays the raw driver code. Catch the type, not a code or a message.instance.delete()andQuery.delete(). Solutions note:docs/solutions/issues/pg18-restrict-sqlstate-23001.md.Closes #306
Fixes #336
Fixes #337
Test plan
cargo test --no-default-features --features testing(207 passed)uv run pytest tests/test_exception_mapping.py --db-backends=sqlite(8 passed)postgres:17) — RESTRICT delete assertssqlstate in {"23503", "23001"}fixOwn the integrity-code table (map 23001 → ForeignKeyViolationError) #336 andtestPin RESTRICT parent-delete as ForeignKeyViolationError #337 closed; this PR closesfixPRD: Classify PG18 RESTRICT (23001) as ForeignKeyViolationError #306Made with Cursor