mirror of https://github.com/go-gorm/gorm.git
Fix statement modifier support
This commit is contained in:
parent
1bbaa43951
commit
56bdded0f8
|
@ -27,6 +27,8 @@ func (db *DB) Clauses(conds ...clause.Expression) (tx *DB) {
|
|||
for _, cond := range conds {
|
||||
if c, ok := cond.(clause.Interface); ok {
|
||||
tx.Statement.AddClause(c)
|
||||
} else if optimizer, ok := cond.(StatementModifier); ok {
|
||||
optimizer.ModifyStatement(tx.Statement)
|
||||
} else {
|
||||
whereConds = append(whereConds, cond)
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func (c Clause) Build(builder Builder) {
|
|||
}
|
||||
|
||||
if c.AfterNameExpression != nil {
|
||||
c.BeforeExpression.Build(builder)
|
||||
c.AfterNameExpression.Build(builder)
|
||||
builder.WriteByte(' ')
|
||||
}
|
||||
|
||||
|
|
|
@ -202,12 +202,11 @@ func (stmt *Statement) AddClause(v clause.Interface) {
|
|||
if optimizer, ok := v.(StatementModifier); ok {
|
||||
optimizer.ModifyStatement(stmt)
|
||||
} else {
|
||||
c, ok := stmt.Clauses[v.Name()]
|
||||
if !ok {
|
||||
c.Name = v.Name()
|
||||
}
|
||||
name := v.Name()
|
||||
c, _ := stmt.Clauses[name]
|
||||
c.Name = name
|
||||
v.MergeClause(&c)
|
||||
stmt.Clauses[v.Name()] = c
|
||||
stmt.Clauses[name] = c
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue