Changed return type to be nullable

This commit is contained in:
thomashii@dukefirehawk.com 2021-05-03 07:49:26 +08:00
parent 106528a93b
commit 81b2e2e6b2
2 changed files with 4 additions and 3 deletions

View file

@ -325,7 +325,7 @@ abstract class Query<T, Where extends QueryWhere?> extends QueryBase<T> {
return super.getOne(executor);
}
Future<List<T>> delete(QueryExecutor executor) {
Future<List<T>?> delete(QueryExecutor executor) {
var sql = compile({}, preamble: 'DELETE', withFields: false);
if (_joins.isEmpty) {
@ -346,7 +346,8 @@ abstract class Query<T, Where extends QueryWhere?> extends QueryBase<T> {
}
Future<T?> deleteOne(QueryExecutor executor) {
return delete(executor).then((it) => it.isEmpty ? null : it.first);
return delete(executor)
.then((it) => it?.isEmpty == true ? null : it?.first);
}
Future<T?> insert(QueryExecutor executor) {

View file

@ -19,5 +19,5 @@ abstract class QueryExecutor {
///
/// Whether nested transactions are supported depends on the
/// underlying driver.
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f);
Future<T?> transaction<T>(FutureOr<T> Function(QueryExecutor) f);
}