From d165ee1bd8f34a79d71ce0d401d5d2a1a5ee8fd2 Mon Sep 17 00:00:00 2001 From: Alexander Wilde Date: Mon, 21 Nov 2022 13:39:06 +0000 Subject: [PATCH] Remove unnecessary where for batch.deleteAll --- drift/lib/src/runtime/api/batch.dart | 7 +++++-- drift/test/database/batch_test.dart | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drift/lib/src/runtime/api/batch.dart b/drift/lib/src/runtime/api/batch.dart index aca5c331..b403c8e3 100644 --- a/drift/lib/src/runtime/api/batch.dart +++ b/drift/lib/src/runtime/api/batch.dart @@ -147,8 +147,11 @@ class Batch { /// /// See also: /// - [DatabaseConnectionUser.delete] - void deleteAll(TableInfo table) => - deleteWhere(table, (tbl) => const Constant(true)); + void deleteAll(TableInfo table) { + _addUpdate(table, UpdateKind.delete); + final stmt = DeleteStatement(_user, table); + _addContext(stmt.constructQuery()); + } /// Executes the custom [sql] statement with variables instantiated to [args]. /// diff --git a/drift/test/database/batch_test.dart b/drift/test/database/batch_test.dart index dadb344b..5d53468a 100644 --- a/drift/test/database/batch_test.dart +++ b/drift/test/database/batch_test.dart @@ -59,7 +59,7 @@ void main() { 'UPDATE "users" SET "name" = ? WHERE "name" = ?;', 'UPDATE "categories" SET "desc" = ?, "priority" = 0 WHERE "id" = ?;', 'DELETE FROM "categories" WHERE "id" = ?;', - 'DELETE FROM "categories" WHERE 1;', + 'DELETE FROM "categories";', 'DELETE FROM "todos" WHERE "id" = ?;', 'some custom statement', ],