Skip to content

Commit

Permalink
Remove duplicated sort fields from order by clause
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 <liubin0329@gmail.com>
  • Loading branch information
liubin committed Sep 12, 2023
1 parent 12ce915 commit 1a57ba8
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
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
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 1a57ba8

Please sign in to comment.