diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart index a708bc2c8011..936d30888066 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart @@ -3891,5 +3891,67 @@ void runQueryTests() { expect(res.docs.map((e) => e.reference), [doc2, doc3]); }); }); + + group('WhereIn Filter', () { + testWidgets('Multiple whereIn filters should not trigger an assertion', + (_) async { + try { + final collection = await initializeTest('multipe-whereIn-clause'); + + Map data = {}; + + for (int i = 1; i <= 10; i++) { + data['field$i'] = 'value$i'; + } + + await collection.doc().set(data); + + Query> query = collection; + data.forEach((field, values) { + query = query.where(field, whereIn: [values]); + }); + + await query.get(); + } on AssertionError catch (e) { + fail('Test failed due to AssertionError: $e'); + } + }); + + testWidgets( + 'Multiple whereIn filters exceeding DNF 30 clause limit should trigger an assertion', + (_) async { + try { + final collection = await initializeTest('multipe-whereIn-clause'); + + await collection.doc().set({'genre': 'fiction'}); + await collection.doc().set({'author': 'Author A'}); + + // DNF for this query = 36 (6 genres * 6 authors) exceeding the 30 clause limit + await collection.where( + 'genre', + whereIn: [ + 'fiction', + 'non-fiction', + 'fantasy', + 'science-fiction', + 'mystery', + 'thriller', + ], + ).where( + 'author', + whereIn: [ + 'Author A', + 'Author B', + 'Author C', + 'Author D', + 'Author E', + 'Author F', + ], + ).get(); + } catch (error) { + expect(error, isA()); + } + }); + }); }); } diff --git a/packages/cloud_firestore/cloud_firestore/lib/src/query.dart b/packages/cloud_firestore/cloud_firestore/lib/src/query.dart index e1ef4953bbd1..cefa3c75883f 100644 --- a/packages/cloud_firestore/cloud_firestore/lib/src/query.dart +++ b/packages/cloud_firestore/cloud_firestore/lib/src/query.dart @@ -765,7 +765,6 @@ class _JsonQuery implements Query> { } if (operator == 'in') { - assert(!hasIn, "You cannot use 'whereIn' filters more than once."); assert( !hasNotIn, "You cannot use 'in' filters with 'not-in' filters.",