@@ -17,7 +17,7 @@ class DatabaseTransactionBase<TABLES extends TablesBase> {
17
17
final TABLES tables;
18
18
static final columnNamePattern = RegExp (r'^[a-z_]+$' );
19
19
20
- void _assertColumnNames (Map <String , Object > values) {
20
+ void _assertColumnNames (Map <String , Object ? > values) {
21
21
assert ((() {
22
22
for (final key in values.keys) {
23
23
if (! columnNamePattern.hasMatch (key)) {
@@ -49,8 +49,8 @@ class DatabaseTransactionBase<TABLES extends TablesBase> {
49
49
50
50
Future <int > executeUpdate (
51
51
String table, {
52
- @ required Map <String , Object > set ,
53
- @ required Map <String , Object > where,
52
+ required Map <String , Object ? > set ,
53
+ required Map <String , Object > where,
54
54
bool setContainsOptional = false ,
55
55
}) async {
56
56
assert (set != null );
@@ -78,14 +78,14 @@ class DatabaseTransactionBase<TABLES extends TablesBase> {
78
78
79
79
/// Removes entries in [values] which have a `null` value, and replaces
80
80
/// all [Optional] values with their actual value.
81
- Map <String , Object > flattenOptionals (Map <String , Object > values) {
82
- Object unwrap (Object value) => value is Optional ? value.orNull : value;
81
+ Map <String , Object ? > flattenOptionals (Map <String , Object ? > values) {
82
+ Object ? unwrap (Object ? value) => value is Optional ? value.orNull : value;
83
83
return Map .fromEntries (values.entries
84
84
.where ((element) => element.value != null )
85
85
.map ((e) => MapEntry (e.key, unwrap (e.value))));
86
86
}
87
87
88
- bool _assertCorrectValues (Map <String , Object > values) {
88
+ bool _assertCorrectValues (Map <String , Object ?> ? values) {
89
89
if (values == null ) {
90
90
return true ;
91
91
}
@@ -103,9 +103,9 @@ class DatabaseTransactionBase<TABLES extends TablesBase> {
103
103
104
104
Future <int > execute (
105
105
String fmtString, {
106
- Map <String , Object > values,
107
- int timeoutInSeconds,
108
- int expectedResultCount,
106
+ Map <String , Object ?> ? values,
107
+ int ? timeoutInSeconds,
108
+ int ? expectedResultCount,
109
109
}) async {
110
110
try {
111
111
assert (_assertCorrectValues (values));
@@ -126,9 +126,9 @@ class DatabaseTransactionBase<TABLES extends TablesBase> {
126
126
}
127
127
128
128
Future <PostgreSQLResult > query (String fmtString,
129
- {Map <String , Object > values,
130
- bool allowReuse,
131
- int timeoutInSeconds}) async {
129
+ {Map <String , Object >? values,
130
+ bool ? allowReuse,
131
+ int ? timeoutInSeconds}) async {
132
132
assert (_assertCorrectValues (values));
133
133
return _conn.query (fmtString,
134
134
substitutionValues: values,
@@ -146,9 +146,9 @@ class CustomBind {
146
146
abstract class DatabaseAccessBase <TX extends DatabaseTransactionBase <TABLES >,
147
147
TABLES extends TablesBase > {
148
148
DatabaseAccessBase ({
149
- @ required this .config,
150
- @ required this .tables,
151
- @ required this .migrations,
149
+ required this .config,
150
+ required this .tables,
151
+ required this .migrations,
152
152
}) : assert (config != null ),
153
153
assert (tables != null ),
154
154
assert (migrations != null );
@@ -157,11 +157,11 @@ abstract class DatabaseAccessBase<TX extends DatabaseTransactionBase<TABLES>,
157
157
final DatabaseConfig config;
158
158
final MigrationsProvider <TX , TABLES > migrations;
159
159
160
- PostgreSQLConnection _conn;
160
+ PostgreSQLConnection ? _conn;
161
161
162
162
Future <PostgreSQLConnection > _connection () async {
163
163
if (_conn != null ) {
164
- return _conn;
164
+ return _conn! ;
165
165
}
166
166
final conn = PostgreSQLConnection (
167
167
config.host,
@@ -185,7 +185,7 @@ abstract class DatabaseAccessBase<TX extends DatabaseTransactionBase<TABLES>,
185
185
}
186
186
187
187
Future <void > dispose () async {
188
- await _conn.close ();
188
+ await _conn! .close ();
189
189
_conn = null ;
190
190
}
191
191
@@ -229,7 +229,7 @@ abstract class DatabaseAccessBase<TX extends DatabaseTransactionBase<TABLES>,
229
229
230
230
final migrationRun = clock.now ().toUtc ();
231
231
await run ((conn) async {
232
- final migrations = this .migrations.migrations;
232
+ final List < Migrations < TX , TABLES >> migrations = this .migrations.migrations;
233
233
for (final migration in migrations) {
234
234
if (migration.id > lastMigration) {
235
235
_logger.fine ('Running migration ${migration .id } '
@@ -315,9 +315,9 @@ abstract class MigrationsProvider<TX extends DatabaseTransactionBase<TABLES>,
315
315
class Migrations <TX extends DatabaseTransactionBase <TABLES >,
316
316
TABLES extends TablesBase > {
317
317
Migrations ({
318
- @ required this .id,
318
+ required this .id,
319
319
this .versionCode = 'a' ,
320
- @ required this .up,
320
+ required this .up,
321
321
}) : assert (id != null ),
322
322
assert (up != null );
323
323
0 commit comments