Skip to content

Commit d770aa6

Browse files
authored
fix(cloud_firestore): remove single whereIn filter assertion (#13436)
1 parent 2ff64ac commit d770aa6

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart

+62
Original file line numberDiff line numberDiff line change
@@ -3891,5 +3891,67 @@ void runQueryTests() {
38913891
expect(res.docs.map((e) => e.reference), [doc2, doc3]);
38923892
});
38933893
});
3894+
3895+
group('WhereIn Filter', () {
3896+
testWidgets('Multiple whereIn filters should not trigger an assertion',
3897+
(_) async {
3898+
try {
3899+
final collection = await initializeTest('multipe-whereIn-clause');
3900+
3901+
Map<String, String> data = {};
3902+
3903+
for (int i = 1; i <= 10; i++) {
3904+
data['field$i'] = 'value$i';
3905+
}
3906+
3907+
await collection.doc().set(data);
3908+
3909+
Query<Map<String, dynamic>> query = collection;
3910+
data.forEach((field, values) {
3911+
query = query.where(field, whereIn: [values]);
3912+
});
3913+
3914+
await query.get();
3915+
} on AssertionError catch (e) {
3916+
fail('Test failed due to AssertionError: $e');
3917+
}
3918+
});
3919+
3920+
testWidgets(
3921+
'Multiple whereIn filters exceeding DNF 30 clause limit should trigger an assertion',
3922+
(_) async {
3923+
try {
3924+
final collection = await initializeTest('multipe-whereIn-clause');
3925+
3926+
await collection.doc().set({'genre': 'fiction'});
3927+
await collection.doc().set({'author': 'Author A'});
3928+
3929+
// DNF for this query = 36 (6 genres * 6 authors) exceeding the 30 clause limit
3930+
await collection.where(
3931+
'genre',
3932+
whereIn: [
3933+
'fiction',
3934+
'non-fiction',
3935+
'fantasy',
3936+
'science-fiction',
3937+
'mystery',
3938+
'thriller',
3939+
],
3940+
).where(
3941+
'author',
3942+
whereIn: [
3943+
'Author A',
3944+
'Author B',
3945+
'Author C',
3946+
'Author D',
3947+
'Author E',
3948+
'Author F',
3949+
],
3950+
).get();
3951+
} catch (error) {
3952+
expect(error, isA<FirebaseException>());
3953+
}
3954+
});
3955+
});
38943956
});
38953957
}

packages/cloud_firestore/cloud_firestore/lib/src/query.dart

-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ class _JsonQuery implements Query<Map<String, dynamic>> {
765765
}
766766

767767
if (operator == 'in') {
768-
assert(!hasIn, "You cannot use 'whereIn' filters more than once.");
769768
assert(
770769
!hasNotIn,
771770
"You cannot use 'in' filters with 'not-in' filters.",

0 commit comments

Comments
 (0)