File tree
Expand file treeCollapse file tree2 files changed
+62
-1
lines changed packages/cloud_firestore/cloud_firestore
Expand file treeCollapse file tree2 files changed
+62
-1
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -3891,5 +3891,67 @@ void runQueryTests() {
|
3891 | 3891 | expect(res.docs.map((e) => e.reference), [doc2, doc3]);
|
3892 | 3892 | });
|
3893 | 3893 | });
|
| 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 | +}); |
3894 | 3956 | });
|
3895 | 3957 | }
|
Original file line number | Diff line number | Diff line change |
---|
@@ -765,7 +765,6 @@ class _JsonQuery implements Query<Map<String, dynamic>> {
|
765 | 765 | }
|
766 | 766 |
|
767 | 767 | if (operator == 'in') {
|
768 |
| -assert(!hasIn, "You cannot use 'whereIn' filters more than once."); |
769 | 768 | assert(
|
770 | 769 | !hasNotIn,
|
771 | 770 | "You cannot use 'in' filters with 'not-in' filters.",
|
|
You can’t perform that action at this time.
0 commit comments