Skip to content

Commit 26a4f6e

Browse files
authored
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>
1 parent ed370a4 commit 26a4f6e

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

src/lib/q/query.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func MustClone(query *Query) *Query {
5656
if query != nil {
5757
q.PageNumber = query.PageNumber
5858
q.PageSize = query.PageSize
59-
q.Sorts = query.Sorts
6059
for k, v := range query.Keywords {
6160
q.Keywords[k] = v
6261
}

src/lib/q/query_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func TestMustClone(t *testing.T) {
3030
}{
3131
{"ptr", args{New(KeyWords{"public": "true"})}, New(KeyWords{"public": "true"})},
3232
{"nil", args{nil}, New(KeyWords{})},
33+
{"sort", args{&Query{Keywords: KeyWords{"public": "true"}, Sorts: []*Sort{NewSort("col-1", true)}}}, &Query{Keywords: KeyWords{"public": "true"}, Sorts: []*Sort{NewSort("col-1", true)}}},
3334
}
3435
for _, tt := range tests {
3536
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)