Skip to content

Commit fb306e5

Browse files
committed
refactor: use slices.Clone to copy Sort slice in GetOrder method
1 parent 43e2776 commit fb306e5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

page.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package pgkit
33
import (
44
"fmt"
55
"regexp"
6+
"slices"
67
"strings"
78

89
sq "github.com/Masterminds/squirrel"
@@ -111,7 +112,7 @@ func (p *Page) SetDefaults(o *PaginatorSettings) {
111112
func (p *Page) GetOrder(columnFunc func(string) string, defaultSort ...string) []Sort {
112113
var sorts []Sort
113114
if p != nil && len(p.Sort) != 0 {
114-
sorts = append(sorts, p.Sort...) // copy to avoid modifying the original slice
115+
sorts = slices.Clone(p.Sort)
115116
}
116117
// fall back to column
117118
if len(sorts) == 0 {

0 commit comments

Comments
 (0)