@@ -120,8 +120,8 @@ void runSecondDatabaseTests() {
120
120
});
121
121
});
122
122
/**
123
- * get
124
- */
123
+ * get
124
+ */
125
125
group ('Query.get()' , () {
126
126
testWidgets ('returns a [QuerySnapshot]' , (_) async {
127
127
CollectionReference <Map <String , dynamic >> collection =
@@ -194,8 +194,8 @@ void runSecondDatabaseTests() {
194
194
});
195
195
196
196
/**
197
- * snapshots
198
- */
197
+ * snapshots
198
+ */
199
199
group ('Query.snapshots()' , () {
200
200
testWidgets ('returns a [Stream]' , (_) async {
201
201
CollectionReference <Map <String , dynamic >> collection =
@@ -340,8 +340,8 @@ void runSecondDatabaseTests() {
340
340
});
341
341
342
342
/**
343
- * End At
344
- */
343
+ * End At
344
+ */
345
345
346
346
group ('Query.endAt{Document}()' , () {
347
347
testWidgets ('ends at string field paths' , (_) async {
@@ -506,8 +506,8 @@ void runSecondDatabaseTests() {
506
506
});
507
507
508
508
/**
509
- * Start At
510
- */
509
+ * Start At
510
+ */
511
511
512
512
group ('Query.startAt{Document}()' , () {
513
513
testWidgets ('starts at string field paths' , (_) async {
@@ -671,8 +671,8 @@ void runSecondDatabaseTests() {
671
671
});
672
672
673
673
/**
674
- * End Before
675
- */
674
+ * End Before
675
+ */
676
676
677
677
group ('Query.endBefore{Document}()' , () {
678
678
testWidgets ('ends before string field paths' , (_) async {
@@ -837,8 +837,8 @@ void runSecondDatabaseTests() {
837
837
});
838
838
839
839
/**
840
- * Start after
841
- */
840
+ * Start after
841
+ */
842
842
group ('Query.startAfter{Document}()' , () {
843
843
testWidgets ('starts after string field paths' , (_) async {
844
844
CollectionReference <Map <String , dynamic >> collection =
@@ -968,8 +968,8 @@ void runSecondDatabaseTests() {
968
968
});
969
969
970
970
/**
971
- * Start & End
972
- */
971
+ * Start & End
972
+ */
973
973
974
974
group ('Query.startAt/endAt' , () {
975
975
testWidgets ('starts at & ends at a document' , (_) async {
@@ -1084,8 +1084,8 @@ void runSecondDatabaseTests() {
1084
1084
});
1085
1085
1086
1086
/**
1087
- * Limit
1088
- */
1087
+ * Limit
1088
+ */
1089
1089
1090
1090
group ('Query.limit{toLast}()' , () {
1091
1091
testWidgets ('limits documents' , (_) async {
@@ -1152,8 +1152,8 @@ void runSecondDatabaseTests() {
1152
1152
});
1153
1153
1154
1154
/**
1155
- * Order
1156
- */
1155
+ * Order
1156
+ */
1157
1157
group ('Query.orderBy()' , () {
1158
1158
testWidgets ('allows ordering by documentId' , (_) async {
1159
1159
CollectionReference <Map <String , dynamic >> collection =
@@ -1236,8 +1236,8 @@ void runSecondDatabaseTests() {
1236
1236
});
1237
1237
1238
1238
/**
1239
- * Where filters
1240
- */
1239
+ * Where filters
1240
+ */
1241
1241
1242
1242
group ('Query.where()' , () {
1243
1243
testWidgets (
@@ -1820,15 +1820,82 @@ void runSecondDatabaseTests() {
1820
1820
Filter ('totalDomesticRevenue' , isEqualTo: 60000000 ),
1821
1821
Filter ('totalWorldwideRevenue' , isEqualTo: 200000000 ),
1822
1822
Filter ('estimatedProfit' , isEqualTo: 140000000 ),
1823
- // Fails because this is not allowed when arrayContainsAny is included in the Query
1823
+ // Inequality causes "failed-precondition" exception and asks user to create an index
1824
1824
Filter ('mainCharacter' , isNotEqualTo: 'MainCharacter2' ),
1825
1825
),
1826
1826
)
1827
1827
.orderBy ('rating' , descending: true )
1828
1828
.get (),
1829
1829
throwsA (
1830
1830
isA <FirebaseException >()
1831
- .having ((e) => e.code, 'code' , 'invalid-argument' ),
1831
+ .having ((e) => e.code, 'code' , 'failed-precondition' )
1832
+ .having (
1833
+ (e) => e.message,
1834
+ 'message' ,
1835
+ contains (
1836
+ 'The query contains range and inequality filters on multiple fields' ,
1837
+ ),
1838
+ ),
1839
+ ),
1840
+ );
1841
+ },
1842
+ );
1843
+
1844
+ testWidgets (
1845
+ 'Exception thrown when combining `arrayContainsAny` & `isNotEqualTo` in multiple conjunctive queries' ,
1846
+ (_) async {
1847
+ CollectionReference <Map <String , dynamic >> collection =
1848
+ await initializeTest ('multiple-conjunctive-queries' );
1849
+
1850
+ await expectLater (
1851
+ collection
1852
+ .where (
1853
+ Filter .and (
1854
+ Filter ('rating1' , isEqualTo: 3.8 ),
1855
+ Filter ('year1' , isEqualTo: 1970 ),
1856
+ Filter ('runtime1' , isEqualTo: 90 ),
1857
+ Filter ('director1' , isEqualTo: 'Director2' ),
1858
+ Filter ('producer1' , isEqualTo: 'Producer2' ),
1859
+ Filter ('budget1' , isEqualTo: 20000000 ),
1860
+ Filter ('boxOffice1' , isEqualTo: 50000000 ),
1861
+ Filter ('actor1' , isEqualTo: 'Actor2' ),
1862
+ Filter ('language1' , isEqualTo: 'English' ),
1863
+ Filter ('award1' , isEqualTo: 'Award2' ),
1864
+ Filter ('genre1' , arrayContainsAny: ['sci-fi' ]),
1865
+ Filter ('country1' , isEqualTo: 'USA' ),
1866
+ Filter ('released1' , isEqualTo: true ),
1867
+ Filter ('screenplay1' , isEqualTo: 'Screenplay2' ),
1868
+ Filter ('cinematography1' , isEqualTo: 'Cinematography2' ),
1869
+ Filter ('music1' , isEqualTo: 'Music2' ),
1870
+ Filter ('rating2' , isEqualTo: 4.2 ),
1871
+ Filter ('year2' , isEqualTo: 1982 ),
1872
+ Filter ('runtime2' , isEqualTo: 60 ),
1873
+ Filter ('director2' , isEqualTo: 'Director3' ),
1874
+ Filter ('producer2' , isEqualTo: 'Producer3' ),
1875
+ Filter ('budget2' , isEqualTo: 30000000 ),
1876
+ Filter ('boxOffice2' , isEqualTo: 60000000 ),
1877
+ Filter ('actor2' , isEqualTo: 'Actor3' ),
1878
+ Filter ('language2' , isEqualTo: 'Korean' ),
1879
+ Filter ('award2' , isEqualTo: 'Award3' ),
1880
+ Filter ('genre2' , isEqualTo: ['sci-fi' , 'action' ]),
1881
+ Filter ('country2' , isEqualTo: 'South Korea' ),
1882
+ Filter ('released2' , isEqualTo: false ),
1883
+ // Inequality causes "failed-precondition" exception and asks user to create an index
1884
+ Filter ('screenplay2' , isNotEqualTo: 'blah' ),
1885
+ ),
1886
+ )
1887
+ .orderBy ('rating1' , descending: true )
1888
+ .get (),
1889
+ throwsA (
1890
+ isA <FirebaseException >()
1891
+ .having ((e) => e.code, 'code' , 'failed-precondition' )
1892
+ .having (
1893
+ (e) => e.message,
1894
+ 'message' ,
1895
+ contains (
1896
+ 'The query contains range and inequality filters on multiple fields' ,
1897
+ ),
1898
+ ),
1832
1899
),
1833
1900
);
1834
1901
},
0 commit comments