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?

Patch my previous PR (I tried to solve check constraints, but unfortunately broke the foreign keys). I am very sorry for that. This time I have tested it thoroughly within a large DB design instead of a small 1 table setup for just 1 use-case.

User Case Description

My previous PR fixed the logic for check constraints. However, this function was apparently also being used for foreign keys.
I tested the previous MR with a very simple table setup with 1 check constraint, without any other constraints.
Now when I implemented this new version into the large eco-system that I'm working on, it failed for foreign keys.
Apparently this function needs to be able to check if a foreign key and/or check constraint does already exist.
I looked up another example in another drive (postgres driver), in which it is possible to just check it in one table (all constraints are stored in the same table). However, within SQL server this is apparently not the case. This is why I have updated the query to check both tables.

@joeriakkerman
Copy link
Contributor Author

@jinzhu Again, sorry to break this driver in my previous PR. I fixed 1 bug, but introduced another.
This PR will fix both issues at once.

@jinzhu jinzhu merged commit ca15d94 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