Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

many2many join table creation fails when forgeignKey has check constraint #7006

Open
greencoda opened this issue May 6, 2024 · 0 comments
Open
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@greencoda
Copy link

greencoda commented May 6, 2024

GORM Playground Link

go-gorm/playground#731

Description

When adding a many2many relationship between models. If one of them has a check constraint, GORM tries to copy it over to the joinTable, where it won't work, since the constraint has a different name for the column (i.e.: email -> user_email)

I'd expect this constraint to either be optionally ignored at schema/relationship.go:

	Tag: removeSettingFromTag(appendSettingFromTag(ownField.StructField.Tag, "primaryKey"),
-		"column", "autoincrement", "index", "unique", "uniqueindex"),
+		"column", "autoincrement", "index", "unique", "uniqueindex", "check"),

or possibly allow users to be able to set the checks on the new reference columns in the struct tags of the field with the many2many relationship.

@github-actions github-actions bot added the type:with reproduction steps with reproduction steps label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:with reproduction steps with reproduction steps
Projects
None yet
Development

No branches or pull requests

2 participants