From ced14c4f71405e200427458c08517c1fa8133c52 Mon Sep 17 00:00:00 2001 From: Markus Richter Date: Tue, 5 May 2020 19:02:13 +0200 Subject: [PATCH] Fix issue #224 --- .../lib/processor/query_method_processor.dart | 2 +- .../test/processor/query_method_processor_test.dart | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/floor_generator/lib/processor/query_method_processor.dart b/floor_generator/lib/processor/query_method_processor.dart index 1793a53a..42ccd22e 100644 --- a/floor_generator/lib/processor/query_method_processor.dart +++ b/floor_generator/lib/processor/query_method_processor.dart @@ -83,7 +83,7 @@ class QueryMethodProcessor extends Processor { if (query == null || query.isEmpty) throw _processorError.noQueryDefined; - final substitutedQuery = query.replaceAll(RegExp(r':[^\s)]+'), '?'); + final substitutedQuery = query.replaceAll(RegExp(r':[.\w]+'), '?'); _assertQueryParameters(substitutedQuery, _methodElement.parameters); return _replaceInClauseArguments(substitutedQuery); } diff --git a/floor_generator/test/processor/query_method_processor_test.dart b/floor_generator/test/processor/query_method_processor_test.dart index c072ba81..4dc93c5c 100644 --- a/floor_generator/test/processor/query_method_processor_test.dart +++ b/floor_generator/test/processor/query_method_processor_test.dart @@ -180,6 +180,18 @@ void main() { expect(actual, equals('SELECT * FROM Persons WHERE name LIKE ?')); }); + + test('Parse query with commas', () async { + final methodElement = await _createQueryMethodElement(''' + @Query('SELECT * FROM :table,:othertable') + Future> findPersonsWithNamesLike(String table, String othertable); + '''); + + final actual = + QueryMethodProcessor(methodElement, [], []).process().query; + + expect(actual, equals('SELECT * FROM ?,?')); + }); }); group('errors', () {