fix: update clause.OrderBy to use Exprs instead of Expression
This commit is contained in:
parent
553f0c62f8
commit
4817f2c3d3
@ -1025,7 +1025,7 @@ func TestOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
stmt := dryDB.Clauses(clause.OrderBy{
|
||||
Expression: clause.Expr{SQL: "FIELD(id,?)", Vars: []interface{}{[]int{1, 2, 3}}, WithoutParentheses: true},
|
||||
Exprs: []clause.Expression{clause.Expr{SQL: "FIELD(id,?)", Vars: []interface{}{[]int{1, 2, 3}}, WithoutParentheses: true}},
|
||||
}).Find(&User{}).Statement
|
||||
|
||||
explainedSQL := dryDB.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)
|
||||
@ -1050,7 +1050,7 @@ func TestOrderWithAllFields(t *testing.T) {
|
||||
}
|
||||
|
||||
stmt := dryDB.Clauses(clause.OrderBy{
|
||||
Expression: clause.Expr{SQL: "FIELD(id,?)", Vars: []interface{}{[]int{1, 2, 3}}, WithoutParentheses: true},
|
||||
Exprs: []clause.Expression{clause.Expr{SQL: "FIELD(id,?)", Vars: []interface{}{[]int{1, 2, 3}}, WithoutParentheses: true}},
|
||||
}).Find(&User{}).Statement
|
||||
|
||||
explainedSQL := dryDB.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)
|
||||
|
@ -449,7 +449,7 @@ func TestToSQL(t *testing.T) {
|
||||
// UpdateColumns
|
||||
sql = DB.ToSQL(func(tx *gorm.DB) *gorm.DB {
|
||||
return tx.Raw("SELECT * FROM users ?", clause.OrderBy{
|
||||
Columns: []clause.OrderByColumn{{Column: clause.Column{Name: "id", Raw: true}, Desc: true}},
|
||||
Exprs: []clause.Expression{clause.OrderByColumn{Column: clause.Column{Name: "id", Raw: true}, Desc: true}},
|
||||
})
|
||||
})
|
||||
assertEqualSQL(t, `SELECT * FROM users ORDER BY id DESC`, sql)
|
||||
|
Loading…
x
Reference in New Issue
Block a user