From 59e1e00ae0abf8a212ee32ccd5920ad2c68b9ba1 Mon Sep 17 00:00:00 2001 From: Moshe Dicker Date: Wed, 3 Apr 2024 21:23:54 -0400 Subject: [PATCH] another bug --- drift/lib/src/runtime/manager/manager.dart | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drift/lib/src/runtime/manager/manager.dart b/drift/lib/src/runtime/manager/manager.dart index 57849a9f..789dbcbb 100644 --- a/drift/lib/src/runtime/manager/manager.dart +++ b/drift/lib/src/runtime/manager/manager.dart @@ -323,9 +323,8 @@ abstract class BaseTableManager< /// /// See also: [RootTableManager.replace], which does not require [filter] statements and /// supports setting fields back to null. - Future write(DT Function(CU o) f) => $state - .buildUpdateStatement() - .write(f($state._getUpdateCompanionBuilder) as Insertable
); + Future write(Insertable
Function(CU o) f) => + $state.buildUpdateStatement().write(f($state._getUpdateCompanionBuilder)); } /// A table manager that can be used to select rows from a table @@ -437,10 +436,10 @@ abstract class RootTableManager< /// /// If the table doesn't have a `rowid`, you can't rely on the return value. /// Still, the future will always complete with an error if the insert fails. - Future create(D Function(CI o) f, + Future create(Insertable Function(CI o) f, {InsertMode? mode, UpsertClause? onConflict}) { return $state.db.into($state._tableAsTableInfo).insert( - f($state._getInsertCompanionBuilder) as Insertable, + f($state._getInsertCompanionBuilder), mode: mode, onConflict: onConflict); } @@ -453,10 +452,10 @@ abstract class RootTableManager< /// exception in that case. Use [createReturningOrNull] when performing an /// insert with an insert mode like [InsertMode.insertOrIgnore] or when using /// a [DoUpdate] with a `where` clause clause. - Future createReturning(D Function(CI o) f, + Future createReturning(Insertable Function(CI o) f, {InsertMode? mode, UpsertClause? onConflict}) { return $state.db.into($state._tableAsTableInfo).insertReturning( - f($state._getInsertCompanionBuilder) as Insertable, + f($state._getInsertCompanionBuilder), mode: mode, onConflict: onConflict); } @@ -466,10 +465,10 @@ abstract class RootTableManager< /// When no row was inserted and no exception was thrown, for instance because /// [InsertMode.insertOrIgnore] was used or because the upsert clause had a /// `where` clause that didn't match, `null` is returned instead. - Future createReturningOrNull(D Function(CI o) f, + Future createReturningOrNull(Insertable Function(CI o) f, {InsertMode? mode, UpsertClause? onConflict}) { return $state.db.into($state._tableAsTableInfo).insertReturningOrNull( - f($state._getInsertCompanionBuilder) as Insertable, + f($state._getInsertCompanionBuilder), mode: mode, onConflict: onConflict); } @@ -486,10 +485,10 @@ abstract class RootTableManager< /// checks. /// [onConflict] can be used to create an upsert clause for engines that /// support it. For details and examples, see [InsertStatement.insert]. - Future bulkCreate(Iterable Function(CI o) f, + Future bulkCreate(Iterable> Function(CI o) f, {InsertMode? mode, UpsertClause? onConflict}) { - return $state.db.batch((b) => b.insertAll($state._tableAsTableInfo, - f($state._getInsertCompanionBuilder) as Iterable>, + return $state.db.batch((b) => b.insertAll( + $state._tableAsTableInfo, f($state._getInsertCompanionBuilder), mode: mode, onConflict: onConflict)); } @@ -505,9 +504,7 @@ abstract class RootTableManager< /// ignores such fields without changing them in the database. /// /// Returns true if a row was affected by this operation. - Future replace(D entity) { - return $state.db - .update($state._tableAsTableInfo) - .replace(entity as Insertable); + Future replace(Insertable entity) { + return $state.db.update($state._tableAsTableInfo).replace(entity); } }