Skip to content

Commit

Permalink
Return empty list of empty list query result (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitusortner authored Feb 8, 2019
1 parent ecbca12 commit 33b2cdb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions floor_generator/lib/writer/query_method_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class QueryMethodWriter implements Writer {
return 'return rows.map((row) => $constructorCall).toList();';
} else {
return '''
if (rows.isEmpty) {
return null;
}
final row = rows.first;
return $constructorCall;
''';
Expand Down Expand Up @@ -87,9 +90,6 @@ class QueryMethodWriter implements Writer {

return '''
final rows = await database.rawQuery('${queryMethod.query}');
if (rows.isEmpty) {
return null;
}
$mapping
''';
}
Expand Down

0 comments on commit 33b2cdb

Please sign in to comment.