Fix migrator GuessConstraintAndTable method for return value for *schema.Check (#4527)

This commit is contained in:
heige 2021-08-03 11:40:57 +08:00 committed by GitHub
parent 413fe587c6
commit 9e5a4e30b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -503,9 +503,10 @@ func (m Migrator) GuessConstraintAndTable(stmt *gorm.Statement, name string) (_
}
if field := stmt.Schema.LookUpField(name); field != nil {
for _, cc := range checkConstraints {
if cc.Field == field {
return nil, &cc, stmt.Table
for k := range checkConstraints {
if checkConstraints[k].Field == field {
v := checkConstraints[k]
return nil, &v, stmt.Table
}
}