MCPcopy
hub / github.com/go-gorm/gorm / ModifyStatement

Method ModifyStatement

soft_delete.go:76–96  ·  view source on GitHub ↗
(stmt *Statement)

Source from the content-addressed store, hash-verified

74}
75
76func (sd SoftDeleteQueryClause) ModifyStatement(stmt *Statement) {
77 if _, ok := stmt.Clauses["soft_delete_enabled"]; !ok && !stmt.Statement.Unscoped {
78 if c, ok := stmt.Clauses["WHERE"]; ok {
79 if where, ok := c.Expression.(clause.Where); ok && len(where.Exprs) >= 1 {
80 for _, expr := range where.Exprs {
81 if orCond, ok := expr.(clause.OrConditions); ok && len(orCond.Exprs) == 1 {
82 where.Exprs = []clause.Expression{clause.And(where.Exprs...)}
83 c.Expression = where
84 stmt.Clauses["WHERE"] = c
85 break
86 }
87 }
88 }
89 }
90
91 stmt.AddClause(clause.Where{Exprs: []clause.Expression{
92 clause.Eq{Column: clause.Column{Table: clause.CurrentTable, Name: sd.Field.DBName}, Value: sd.ZeroValue},
93 }})
94 stmt.Clauses["soft_delete_enabled"] = clause.Clause{}
95 }
96}
97
98func (DeletedAt) UpdateClauses(f *schema.Field) []clause.Interface {
99 return []clause.Interface{SoftDeleteUpdateClause{Field: f, ZeroValue: parseZeroValueTag(f)}}

Callers

nothing calls this directly

Calls 2

AndFunction · 0.92
AddClauseMethod · 0.80

Tested by

no test coverage detected