From 33b2cdb7a8f43530f4f7ea75503925a8ab94b6cb Mon Sep 17 00:00:00 2001 From: Vitus Date: Fri, 8 Feb 2019 21:19:36 +0100 Subject: [PATCH] Return empty list of empty list query result (#32) --- floor_generator/lib/writer/query_method_writer.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/floor_generator/lib/writer/query_method_writer.dart b/floor_generator/lib/writer/query_method_writer.dart index c5492e6e..4a2aa2bc 100644 --- a/floor_generator/lib/writer/query_method_writer.dart +++ b/floor_generator/lib/writer/query_method_writer.dart @@ -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; '''; @@ -87,9 +90,6 @@ class QueryMethodWriter implements Writer { return ''' final rows = await database.rawQuery('${queryMethod.query}'); - if (rows.isEmpty) { - return null; - } $mapping '''; }