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