mirror of https://github.com/AMT-Cheif/drift.git
parent
a6e4a3669c
commit
c5c8dc7d6d
|
@ -13,6 +13,7 @@
|
|||
To create them in `onUpgrade`, use the new `createIndex` and `createTrigger` functions on a `Migrator`.
|
||||
- Support for moor-file queries that run on initialization ([#280](https://github.com/simolus3/moor/issues/280))
|
||||
Declare them like this `@create: INSERT INTO users VALUES ('default', 'user')`
|
||||
- Support deletes in batches ([#325](https://github.com/simolus3/moor/issues/325))
|
||||
|
||||
## 2.2.0
|
||||
|
||||
|
|
|
@ -94,6 +94,16 @@ class Batch {
|
|||
}
|
||||
}
|
||||
|
||||
/// Deletes all rows from [table] matching the provided [filter].
|
||||
///
|
||||
/// See also:
|
||||
/// - [QueryEngine.delete]
|
||||
void delete<T extends Table, D extends DataClass>(TableInfo<T, D> table,
|
||||
Expression<bool, BoolType> Function(T tbl) filter) {
|
||||
final stmt = DeleteStatement(_engine, table)..where(filter);
|
||||
_addContext(stmt.constructQuery());
|
||||
}
|
||||
|
||||
void _addContext(GenerationContext ctx) {
|
||||
final sql = ctx.sql;
|
||||
final variableSet = _createdStatements.putIfAbsent(sql, () => []);
|
||||
|
|
|
@ -37,6 +37,8 @@ void main() {
|
|||
CategoriesCompanion(id: Value(1), description: Value('new1')),
|
||||
CategoriesCompanion(id: Value(2), description: Value('new2')),
|
||||
]);
|
||||
|
||||
b.delete(db.categories, (_) => const Constant(true));
|
||||
});
|
||||
|
||||
final transaction = executor.transactions;
|
||||
|
@ -67,6 +69,10 @@ void main() {
|
|||
['new2', 2],
|
||||
],
|
||||
),
|
||||
BatchedStatement(
|
||||
'DELETE FROM categories WHERE 1;',
|
||||
[[]],
|
||||
),
|
||||
]));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue