Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
defool committed Sep 16, 2022
2 parents c547def + 4906259 commit cb005b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions callbacks/update.go
Expand Up @@ -70,10 +70,12 @@ func Update(config *Config) func(db *gorm.DB) {
if db.Statement.SQL.Len() == 0 {
db.Statement.SQL.Grow(180)
db.Statement.AddClauseIfNotExists(clause.Update{})
if set := ConvertToAssignments(db.Statement); len(set) != 0 {
db.Statement.AddClause(set)
} else if _, ok := db.Statement.Clauses["SET"]; !ok {
return
if _, ok := db.Statement.Clauses["SET"]; !ok {
if set := ConvertToAssignments(db.Statement); len(set) != 0 {
db.Statement.AddClause(set)
} else {
return
}
}

db.Statement.Build(db.Statement.BuildClauses...)
Expand Down
10 changes: 5 additions & 5 deletions migrator/migrator.go
Expand Up @@ -153,12 +153,12 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
}
}
}
}

for _, chk := range stmt.Schema.ParseCheckConstraints() {
if !queryTx.Migrator().HasConstraint(value, chk.Name) {
if err := execTx.Migrator().CreateConstraint(value, chk.Name); err != nil {
return err
}
for _, chk := range stmt.Schema.ParseCheckConstraints() {
if !queryTx.Migrator().HasConstraint(value, chk.Name) {
if err := tx.Migrator().CreateConstraint(value, chk.Name); err != nil {
return err
}
}
}
Expand Down

0 comments on commit cb005b2

Please sign in to comment.