Skip to content

Set match_tenant? on polymorphic references - #231

Merged
zachdaniel merged 1 commit into
ash-project:mainfrom
C-Sinclair:fix-polymorphic-match-tenant
Sep 18, 2026
Merged

zachdaniel merged 1 commit into
ash-project:mainfrom
C-Sinclair:fix-polymorphic-match-tenant

Conversation

@C-Sinclair

@C-Sinclair C-Sinclair commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

mix ash.codegen --check is currently failing on mainraising "SQLite does not support dropping foreign key constraints.". This one line fixes the issue.

I'm not super familiar with how the match_tenant? flag works, so extra scrutiny required for anything toggling this over would do downstream. But it appears to just be a missed location from 7572718

The reference map built for a polymorphic relationship never set
match_tenant?, so merge_references/3 asked merge_uniq!/4 for a key that
was absent, got an empty list, and returned nil. Snapshots normalise the
key to false on read, so nil != false made every polymorphic reference
compare as changed.

The generator then emitted an alter-constraint operation, which on SQLite
renders as a migration whose up/0 opens by raising "SQLite does not
support dropping foreign key constraints". mix ash.codegen --check
reported three pending files on main and the migration it wanted to write
could not have run.

No snapshot changes: with the key set, the computed references match the
committed ones.
@C-Sinclair
C-Sinclair marked this pull request as ready for review September 18, 2026 19:43
@zachdaniel
zachdaniel merged commit 353566f into ash-project:main Sep 18, 2026
51 checks passed
@zachdaniel

Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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