Remove duplicated sort fields from order by clause (#19347)

In MustClone() it will set Sorts field twice, that will
generate two duplicated order by fields in the generated SQL.

Signed-off-by: bin liu <liubin0329@gmail.com>
This commit is contained in:
Bin Liu 2023-09-17 02:01:30 +08:00 committed by GitHub
parent ed370a496b
commit 26a4f6eeea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 1 deletions

View File

@ -56,7 +56,6 @@ func MustClone(query *Query) *Query {
if query != nil {
q.PageNumber = query.PageNumber
q.PageSize = query.PageSize
q.Sorts = query.Sorts
for k, v := range query.Keywords {
q.Keywords[k] = v
}

View File

@ -30,6 +30,7 @@ func TestMustClone(t *testing.T) {
}{
{"ptr", args{New(KeyWords{"public": "true"})}, New(KeyWords{"public": "true"})},
{"nil", args{nil}, New(KeyWords{})},
{"sort", args{&Query{Keywords: KeyWords{"public": "true"}, Sorts: []*Sort{NewSort("col-1", true)}}}, &Query{Keywords: KeyWords{"public": "true"}, Sorts: []*Sort{NewSort("col-1", true)}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {