Fix limit clause not being copied to join (#433)

This commit is contained in:
Simon Binder 2020-03-08 12:03:34 +01:00
parent e773adab59
commit b2285e04ef
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
3 changed files with 17 additions and 0 deletions

View File

@ -2,6 +2,8 @@
- Fix `beforeOpen` callback deadlocking when using the isolate executor
([#431](https://github.com/simolus3/moor/issues/431))
- Fix limit clause not being applied when using `.join` afterwards
([#433](https://github.com/simolus3/moor/issues/433))
## 2.4.1

View File

@ -74,6 +74,9 @@ class SimpleSelectStatement<T extends Table, D extends DataClass>
if (orderByExpr != null) {
statement.orderBy(orderByExpr.terms);
}
if (limitExpr != null) {
statement.limitExpr = limitExpr;
}
return statement;
}

View File

@ -116,6 +116,18 @@ void main() {
argThat(contains('WHERE t.id < ? ORDER BY t.title ASC')), [3]));
});
test('limit clause is kept', () async {
final todos = db.alias(db.todosTable, 't');
final categories = db.alias(db.categories, 'c');
final normalQuery = db.select(todos)..limit(10, offset: 5);
await normalQuery.join(
[innerJoin(categories, categories.id.equalsExp(todos.category))]).get();
verify(executor.runSelect(argThat(contains('LIMIT 10 OFFSET 5')), []));
});
test('can be watched', () {
final todos = db.alias(db.todosTable, 't');
final categories = db.alias(db.categories, 'c');