order by will be ignored

This commit is contained in:
Lunny Xiao 2023-07-25 16:58:50 +08:00
parent 12d3e1f4ac
commit d8e8474e1c
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 5 additions and 0 deletions

View File

@ -125,6 +125,11 @@ func TestWithTableName(t *testing.T) {
total, err = testEngine.OrderBy("count(`id`) desc").Count(CountWithTableName{}) total, err = testEngine.OrderBy("count(`id`) desc").Count(CountWithTableName{})
assert.NoError(t, err) assert.NoError(t, err)
assert.EqualValues(t, 2, total) assert.EqualValues(t, 2, total)
// the orderby will be ignored by count because some databases will return errors if the orderby columns not in group by
total, err = testEngine.OrderBy("`name`").Count(CountWithTableName{})
assert.NoError(t, err)
assert.EqualValues(t, 2, total)
} }
func TestCountWithSelectCols(t *testing.T) { func TestCountWithSelectCols(t *testing.T) {