You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
388 B
23 lines
388 B
package sqlingo
|
|
|
|
// OrderBy indicates the ORDER BY column and the status of descending order.
|
|
type OrderBy interface {
|
|
GetSQL(scope scope) (string, error)
|
|
}
|
|
|
|
type orderBy struct {
|
|
by Expression
|
|
desc bool
|
|
}
|
|
|
|
func (o orderBy) GetSQL(scope scope) (string, error) {
|
|
sql, err := o.by.GetSQL(scope)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
if o.desc {
|
|
sql += " DESC"
|
|
}
|
|
return sql, nil
|
|
}
|