Skip to content

Conversation

@joeriakkerman
Copy link
Contributor

  • [ x ] Do only one thing
  • [ x ] Non breaking API changes
  • [ x ] Tested

What did this pull request do?

In this PR, the HasConstraint function has been patched, to query the correct table (sys.check_constraints) in SQL server.

User Case Description

I am using check constraints with GORM, however, every time I run the auto migrate, it will try to create the check constraints over and over again, even though they already exist. After some investigation, I came across this query, which will run on the wrong table: sys.foreign_keys, which should be: sys.check_constraints.

@joeriakkerman
Copy link
Contributor Author

@jinzhu cc

@jinzhu jinzhu merged commit 9f27d70 into go-gorm:master Nov 7, 2025
3 checks passed
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