mirror of https://github.com/go-gorm/gorm.git
Fix update select clause with before/after expressions, close #5164
This commit is contained in:
parent
d402765f69
commit
540b47571a
|
@ -93,7 +93,11 @@ func (db *DB) Select(query interface{}, args ...interface{}) (tx *DB) {
|
|||
return
|
||||
}
|
||||
}
|
||||
delete(tx.Statement.Clauses, "SELECT")
|
||||
|
||||
if clause, ok := tx.Statement.Clauses["SELECT"]; ok {
|
||||
clause.Expression = nil
|
||||
tx.Statement.Clauses["SELECT"] = clause
|
||||
}
|
||||
case string:
|
||||
if strings.Count(v, "?") >= len(args) && len(args) > 0 {
|
||||
tx.Statement.AddClause(clause.Select{
|
||||
|
@ -123,7 +127,10 @@ func (db *DB) Select(query interface{}, args ...interface{}) (tx *DB) {
|
|||
}
|
||||
}
|
||||
|
||||
delete(tx.Statement.Clauses, "SELECT")
|
||||
if clause, ok := tx.Statement.Clauses["SELECT"]; ok {
|
||||
clause.Expression = nil
|
||||
tx.Statement.Clauses["SELECT"] = clause
|
||||
}
|
||||
}
|
||||
default:
|
||||
tx.AddError(fmt.Errorf("unsupported select args %v %v", query, args))
|
||||
|
|
Loading…
Reference in New Issue