Fixed null-safety error

This commit is contained in:
thomashii 2022-01-02 18:12:51 +08:00
parent c5286ea623
commit 8666997832
6 changed files with 29 additions and 47 deletions

View file

@ -575,7 +575,7 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
.toString()
.replaceAll('?', '');
merge.add('''
$name: $typeLiteral.from(l.$name ?? [])..addAll(model.$name ?? [])
$name: $typeLiteral.from(l.$name)..addAll(model.$name)
''');
}
});

View file

@ -118,7 +118,7 @@ void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
fooOpt.ifPresent((foo) {
//print(foo.toJson());
//print(weirdJoin!.toJson());
expect(foo.weirdJoins![0].id, weirdJoin!.id);
expect(foo.weirdJoins[0].id, weirdJoin!.id);
});
});
});

View file

@ -139,8 +139,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
users: List<_User>.from(l.users ?? [])
..addAll(model.users ?? []));
users: List<_User>.from(l.users)..addAll(model.users));
}
});
});
@ -158,8 +157,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
users: List<_User>.from(l.users ?? [])
..addAll(model.users ?? []));
users: List<_User>.from(l.users)..addAll(model.users));
}
});
});
@ -177,8 +175,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
users: List<_User>.from(l.users ?? [])
..addAll(model.users ?? []));
users: List<_User>.from(l.users)..addAll(model.users));
}
});
});
@ -420,8 +417,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
roles: List<_Role>.from(l.roles ?? [])
..addAll(model.roles ?? []));
roles: List<_Role>.from(l.roles)..addAll(model.roles));
}
});
});
@ -439,8 +435,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
roles: List<_Role>.from(l.roles ?? [])
..addAll(model.roles ?? []));
roles: List<_Role>.from(l.roles)..addAll(model.roles));
}
});
});
@ -458,8 +453,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
roles: List<_Role>.from(l.roles ?? [])
..addAll(model.roles ?? []));
roles: List<_Role>.from(l.roles)..addAll(model.roles));
}
});
});

View file

@ -133,8 +133,7 @@ class TreeQuery extends Query<Tree, TreeQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
fruits: List<_Fruit>.from(l.fruits ?? [])
..addAll(model.fruits ?? []));
fruits: List<_Fruit>.from(l.fruits)..addAll(model.fruits));
}
});
});
@ -152,8 +151,7 @@ class TreeQuery extends Query<Tree, TreeQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
fruits: List<_Fruit>.from(l.fruits ?? [])
..addAll(model.fruits ?? []));
fruits: List<_Fruit>.from(l.fruits)..addAll(model.fruits));
}
});
});
@ -171,8 +169,7 @@ class TreeQuery extends Query<Tree, TreeQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
fruits: List<_Fruit>.from(l.fruits ?? [])
..addAll(model.fruits ?? []));
fruits: List<_Fruit>.from(l.fruits)..addAll(model.fruits));
}
});
});

View file

@ -321,9 +321,8 @@ class WeirdJoinQuery extends Query<WeirdJoin, WeirdJoinQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
numbas: List<_Numba>.from(l.numbas ?? [])
..addAll(model.numbas ?? []),
foos: List<_Foo>.from(l.foos ?? [])..addAll(model.foos ?? []));
numbas: List<_Numba>.from(l.numbas)..addAll(model.numbas),
foos: List<_Foo>.from(l.foos)..addAll(model.foos));
}
});
});
@ -341,9 +340,8 @@ class WeirdJoinQuery extends Query<WeirdJoin, WeirdJoinQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
numbas: List<_Numba>.from(l.numbas ?? [])
..addAll(model.numbas ?? []),
foos: List<_Foo>.from(l.foos ?? [])..addAll(model.foos ?? []));
numbas: List<_Numba>.from(l.numbas)..addAll(model.numbas),
foos: List<_Foo>.from(l.foos)..addAll(model.foos));
}
});
});
@ -361,9 +359,8 @@ class WeirdJoinQuery extends Query<WeirdJoin, WeirdJoinQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
numbas: List<_Numba>.from(l.numbas ?? [])
..addAll(model.numbas ?? []),
foos: List<_Foo>.from(l.foos ?? [])..addAll(model.foos ?? []));
numbas: List<_Numba>.from(l.numbas)..addAll(model.numbas),
foos: List<_Foo>.from(l.foos)..addAll(model.foos));
}
});
});
@ -696,8 +693,8 @@ class FooQuery extends Query<Foo, FooQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
weirdJoins: List<_WeirdJoin>.from(l.weirdJoins ?? [])
..addAll(model.weirdJoins ?? []));
weirdJoins: List<_WeirdJoin>.from(l.weirdJoins)
..addAll(model.weirdJoins));
}
});
});
@ -715,8 +712,8 @@ class FooQuery extends Query<Foo, FooQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
weirdJoins: List<_WeirdJoin>.from(l.weirdJoins ?? [])
..addAll(model.weirdJoins ?? []));
weirdJoins: List<_WeirdJoin>.from(l.weirdJoins)
..addAll(model.weirdJoins));
}
});
});
@ -734,8 +731,8 @@ class FooQuery extends Query<Foo, FooQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
weirdJoins: List<_WeirdJoin>.from(l.weirdJoins ?? [])
..addAll(model.weirdJoins ?? []));
weirdJoins: List<_WeirdJoin>.from(l.weirdJoins)
..addAll(model.weirdJoins));
}
});
});

View file

@ -154,8 +154,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
roles: List<_Role>.from(l.roles ?? [])
..addAll(model.roles ?? []));
roles: List<_Role>.from(l.roles)..addAll(model.roles));
}
});
});
@ -173,8 +172,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
roles: List<_Role>.from(l.roles ?? [])
..addAll(model.roles ?? []));
roles: List<_Role>.from(l.roles)..addAll(model.roles));
}
});
});
@ -192,8 +190,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
roles: List<_Role>.from(l.roles ?? [])
..addAll(model.roles ?? []));
roles: List<_Role>.from(l.roles)..addAll(model.roles));
}
});
});
@ -495,8 +492,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
users: List<_User>.from(l.users ?? [])
..addAll(model.users ?? []));
users: List<_User>.from(l.users)..addAll(model.users));
}
});
});
@ -514,8 +510,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
users: List<_User>.from(l.users ?? [])
..addAll(model.users ?? []));
users: List<_User>.from(l.users)..addAll(model.users));
}
});
});
@ -533,8 +528,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
var l = out[idx];
return out
..[idx] = l.copyWith(
users: List<_User>.from(l.users ?? [])
..addAll(model.users ?? []));
users: List<_User>.from(l.users)..addAll(model.users));
}
});
});