From 4817f2c3d33ec9b591f7b3d54aa4e01d143ec87b Mon Sep 17 00:00:00 2001 From: Or Ben Chitrit <10655932+Orbsynated@users.noreply.github.com> Date: Wed, 19 Feb 2025 21:29:28 +0200 Subject: [PATCH] fix: update clause.OrderBy to use Exprs instead of Expression --- tests/query_test.go | 4 ++-- tests/sql_builder_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/query_test.go b/tests/query_test.go index 566763c5..77101211 100644 --- a/tests/query_test.go +++ b/tests/query_test.go @@ -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...) diff --git a/tests/sql_builder_test.go b/tests/sql_builder_test.go index 0c204db4..d18c158b 100644 --- a/tests/sql_builder_test.go +++ b/tests/sql_builder_test.go @@ -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)