| 107 | } |
| 108 | |
| 109 | func checkMissingWhereConditions(db *gorm.DB) { |
| 110 | if !db.AllowGlobalUpdate && db.Error == nil { |
| 111 | where, withCondition := db.Statement.Clauses["WHERE"] |
| 112 | if withCondition { |
| 113 | if _, withSoftDelete := db.Statement.Clauses["soft_delete_enabled"]; withSoftDelete { |
| 114 | whereClause, _ := where.Expression.(clause.Where) |
| 115 | withCondition = len(whereClause.Exprs) > 1 |
| 116 | } |
| 117 | } |
| 118 | if !withCondition { |
| 119 | db.AddError(gorm.ErrMissingWhereClause) |
| 120 | } |
| 121 | return |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | type visitMap = map[reflect.Value]bool |
| 126 | |