support sort none

This commit is contained in:
Anker Jam 2020-10-25 23:16:41 +08:00
parent 544c621017
commit b1d5ba8ece
2 changed files with 7 additions and 6 deletions

View File

@ -434,9 +434,9 @@ func (t *dbTables) getOrderSQL(orders []*clauses.Order) (orderSQL string) {
column := order.GetColumn()
var sort string
switch order.GetSort() {
case clauses.ASCENDING:
case clauses.SortAscending:
sort = "ASC"
case clauses.DESCENDING:
case clauses.SortDescending:
sort = "DESC"
}
clause := strings.Split(column, ExprSep)

View File

@ -3,8 +3,9 @@ package clauses
type Sort int8
const (
ASCENDING Sort = 1
DESCENDING Sort = 2
SortNone Sort = 0
SortAscending Sort = 1
SortDescending Sort = 2
)
type Order struct {
@ -23,10 +24,10 @@ func (o *Order) GetSort() Sort {
func ParseOrder(expressions ...string) []*Order {
var orders []*Order
for _, expression := range expressions {
sort := ASCENDING
sort := SortAscending
column := expression
if expression[0] == '-' {
sort = DESCENDING
sort = SortDescending
column = expression[1:]
}