fix: LIMIT clause not valid in DELETE or UPDATE SQL

This commit is contained in:
hujinbiao 2021-03-16 19:28:51 +08:00
parent 2055e29eb8
commit a741113f4f
2 changed files with 2 additions and 2 deletions

View File

@ -135,7 +135,7 @@ func Delete(db *gorm.DB) {
} }
db.Statement.AddClauseIfNotExists(clause.From{}) db.Statement.AddClauseIfNotExists(clause.From{})
db.Statement.Build("DELETE", "FROM", "WHERE") db.Statement.Build("DELETE", "FROM", "WHERE", "LIMIT")
} }
if _, ok := db.Statement.Clauses["WHERE"]; !db.AllowGlobalUpdate && !ok && db.Error == nil { if _, ok := db.Statement.Clauses["WHERE"]; !db.AllowGlobalUpdate && !ok && db.Error == nil {

View File

@ -66,7 +66,7 @@ func Update(db *gorm.DB) {
} else { } else {
return return
} }
db.Statement.Build("UPDATE", "SET", "WHERE") db.Statement.Build("UPDATE", "SET", "WHERE", "LIMIT")
} }
if _, ok := db.Statement.Clauses["WHERE"]; !db.AllowGlobalUpdate && !ok { if _, ok := db.Statement.Clauses["WHERE"]; !db.AllowGlobalUpdate && !ok {