Skip to content

Commit

Permalink
Merge pull request #3 from dkaera/fix/query_return_void_check
Browse files Browse the repository at this point in the history
Fix null pointer exception during the generation queries which return…
  • Loading branch information
dkaera authored Aug 4, 2022
2 parents 1c66273 + 9beaf02 commit 3ea9e56
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 2 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "41.0.0"
version: "43.0.0"
analyzer:
dependency: "direct dev"
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.0"
args:
version: "4.3.1"
dependency: transitive
description:
name: args
Expand Down
3 changes: 2 additions & 1 deletion floor_generator/lib/misc/type_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ extension DartTypeChecker on DartType {

bool get isUint8List => _uint8ListTypeChecker.isExactlyType(this);

bool get isStream => _streamTypeChecker.isExactlyType(this);
extension StreamTypeChecker on DartType {
bool get isStream => !isVoid && _streamTypeChecker.isExactlyType(this);
}

extension FlattenUtil on DartType {
Expand Down
10 changes: 10 additions & 0 deletions floor_generator/test/writer/query_method_writer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,16 @@ void main() {

expect(actual, throwsA(const TypeMatcher<InvalidGenerationSourceError>()));
});

test('query with unsupported return type throws', () async {
final queryMethod = () => _createQueryMethod('''
@Query('DELETE * FROM Person WHERE name = :name')
void deleteByName(String name);
''');

expect(queryMethod,
throwsA(const TypeMatcher<InvalidGenerationSourceError>()));
});
}

Future<QueryMethod> _createQueryMethod(final String methodSignature) async {
Expand Down

0 comments on commit 3ea9e56

Please sign in to comment.