mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
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:
parent
ed370a496b
commit
26a4f6eeea
@ -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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user