WriteOrderBy writes order by
(cols []*model.ColumnInfo, desc bool)
| 220 | |
| 221 | // WriteOrderBy writes order by |
| 222 | func (b *SQLBuilder) WriteOrderBy(cols []*model.ColumnInfo, desc bool) error { |
| 223 | if b.state != writeSelOrDel && b.state != writeWhere { |
| 224 | return errors.Errorf("invalid state: %v", b.state) |
| 225 | } |
| 226 | b.state = writeOrderBy |
| 227 | b.restoreCtx.WritePlain(" ORDER BY ") |
| 228 | b.writeColNames(cols, false) |
| 229 | if desc { |
| 230 | b.restoreCtx.WritePlain(" DESC") |
| 231 | } else { |
| 232 | b.restoreCtx.WritePlain(" ASC") |
| 233 | } |
| 234 | return nil |
| 235 | } |
| 236 | |
| 237 | // WriteLimit writes the limit |
| 238 | func (b *SQLBuilder) WriteLimit(n int) error { |