Skip to content

Commit

Permalink
Remove duplicated sort fields from order by clause (#19347)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
liubin authored Sep 16, 2023
1 parent ed370a4 commit 26a4f6e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 0 additions & 1 deletion src/lib/q/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/q/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 26a4f6e

Please sign in to comment.