* Always put ORDER BY before LIMIT.

This commit is contained in:
Tobe O 2019-08-17 18:08:49 -04:00
parent fa01fd982e
commit f18c23c5f9
2 changed files with 3 additions and 2 deletions

View file

@ -6,6 +6,7 @@ callbacks.
* Make `JoinBuilder` take `to` as a `String Function()`. This will allow
ORM queries to reference their joined subqueries.
* Removed deprecated `Join`, `toSql`, `sanitizeExpression`, `isAscii`.
* Always put `ORDER BY` before `LIMIT`.
# 2.0.1
* Apply `package:pedantic` fixes.

View file

@ -241,12 +241,12 @@ abstract class Query<T, Where extends QueryWhere> extends QueryBase<T> {
var whereClause =
where.compile(tableName: includeTableName ? tableName : null);
if (whereClause.isNotEmpty) b.write(' WHERE $whereClause');
if (_limit != null) b.write(' LIMIT $_limit');
if (_offset != null) b.write(' OFFSET $_offset');
if (_groupBy != null) b.write(' GROUP BY $_groupBy');
for (var item in _orderBy) {
b.write(' ORDER BY ${item.compile()}');
}
if (_limit != null) b.write(' LIMIT $_limit');
if (_offset != null) b.write(' OFFSET $_offset');
return b.toString();
}