Skip to content

fix: omit source check constraints from many-to-many join tables - #7880

Open
binaryyang wants to merge 1 commit into
go-gorm:masterfrom
binaryyang:codex/fix-many2many-check-constraints
Open

binaryyang wants to merge 1 commit into
go-gorm:masterfrom
binaryyang:codex/fix-many2many-check-constraints

Conversation

@binaryyang

Copy link
Copy Markdown
  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Exclude check tags from both source fields when constructing an automatic many-to-many join table. These constraints refer to columns on the original tables; copying them to renamed join columns causes AutoMigrate to fail (for example, email <> '' is copied onto a table containing checked_user_email, producing no such column: email). The original tables retain their CHECK constraints.

Fixes #7006.

Validation

The regression test fails on unmodified master with inherited constraints and a SQLite migration error. With the fix, it verifies successful migration and association insertion, absence of inherited join-table checks, and enforcement of checks on both original tables.

  • go test ./... -count=1 in the root module: passed.
  • Full SQLite integration suite in tests/, using a temporary modfile to resolve the existing missing dependency checksums: passed.

Other database dialects were not run locally.

This branch has not been deployed

No deployments
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.

many2many join table creation fails when forgeignKey has check constraint

1 participant