Updated pubspec.yaml

This commit is contained in:
thomashii@dukefirehawk.com 2021-05-03 22:05:25 +08:00
parent 2d6fdfbe8a
commit a4ff96a831
3 changed files with 8 additions and 4 deletions

View file

@ -9,6 +9,7 @@ dependencies:
intl: ^0.17.0 intl: ^0.17.0
meta: ^1.3.0 meta: ^1.3.0
string_scanner: ^1.1.0 string_scanner: ^1.1.0
optional: ^6.0.0-nullsafety.2
dev_dependencies: dev_dependencies:
angel_model: angel_model:
git: git:
@ -28,4 +29,3 @@ dev_dependencies:
build_runner: ^2.0.1 build_runner: ^2.0.1
pedantic: ^1.11.0 pedantic: ^1.11.0
test: ^1.17.3 test: ^1.17.3
optional: ^6.0.0-nullsafety.2

View file

@ -41,7 +41,7 @@ class PostgreSqlExecutor extends QueryExecutor {
} }
@override @override
Future<T?> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async { Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
if (_connection is! PostgreSQLConnection) { if (_connection is! PostgreSQLConnection) {
return await f(this); return await f(this);
} }
@ -54,6 +54,8 @@ class PostgreSqlExecutor extends QueryExecutor {
logger?.fine('Entering transaction'); logger?.fine('Entering transaction');
var tx = PostgreSqlExecutor(ctx, logger: logger); var tx = PostgreSqlExecutor(ctx, logger: logger);
returnValue = await f(tx); returnValue = await f(tx);
return returnValue;
} catch (e) { } catch (e) {
ctx.cancelTransaction(reason: e.toString()); ctx.cancelTransaction(reason: e.toString());
rethrow; rethrow;
@ -70,7 +72,7 @@ class PostgreSqlExecutor extends QueryExecutor {
'The transaction was cancelled with reason "${txResult.reason}".'); 'The transaction was cancelled with reason "${txResult.reason}".');
//} //}
} else { } else {
return returnValue; return returnValue!;
} }
} }
} }
@ -136,7 +138,7 @@ class PostgreSqlExecutorPool extends QueryExecutor {
} }
@override @override
Future<T?> transaction<T>(FutureOr<T> Function(QueryExecutor) f) { Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) {
return _pool.withResource(() async { return _pool.withResource(() async {
var executor = await _next(); var executor = await _next();
return executor.transaction(f); return executor.transaction(f);

View file

@ -14,6 +14,7 @@ dependencies:
logging: ^1.0.1 logging: ^1.0.1
pool: ^1.5.0 pool: ^1.5.0
postgres: ^2.3.2 postgres: ^2.3.2
#optional: ^6.0.0-nullsafety.2
dev_dependencies: dev_dependencies:
angel_orm_test: angel_orm_test:
@ -27,6 +28,7 @@ dev_dependencies:
ref: sdk-2.12.x_nnbd ref: sdk-2.12.x_nnbd
path: packages/pretty_logging path: packages/pretty_logging
test: ^1.17.3 test: ^1.17.3
#dependency_overrides: #dependency_overrides:
# angel_orm_test: # angel_orm_test:
# path: ../angel_orm_test # path: ../angel_orm_test