fix asc and desc clause

This commit is contained in:
leiwingqueen 2024-03-01 18:35:35 +08:00
parent b48e273924
commit 70e3838441
1 changed files with 10 additions and 4 deletions

View File

@ -118,11 +118,14 @@ func (statement *Statement) Desc(colNames ...string) *Statement {
} }
for _, colName := range colNames { for _, colName := range colNames {
ob := orderBy{colName, nil, "DESC"} ob := orderBy{colName, nil, "DESC"}
statement.orderBy = append(statement.orderBy, ob) notNil, err := ob.CheckValid()
if _, err := ob.CheckValid(); err != nil { if err != nil {
statement.LastError = err statement.LastError = err
return statement return statement
} }
if notNil {
statement.orderBy = append(statement.orderBy, ob)
}
} }
return statement return statement
} }
@ -135,11 +138,14 @@ func (statement *Statement) Asc(colNames ...string) *Statement {
} }
for _, colName := range colNames { for _, colName := range colNames {
ob := orderBy{colName, nil, "ASC"} ob := orderBy{colName, nil, "ASC"}
statement.orderBy = append(statement.orderBy, ob) notNil, err := ob.CheckValid()
if _, err := ob.CheckValid(); err != nil { if err != nil {
statement.LastError = err statement.LastError = err
return statement return statement
} }
if notNil {
statement.orderBy = append(statement.orderBy, ob)
}
} }
return statement return statement
} }