Skip to content

Commit 8da6951

Browse files
authored
fix(firestore): Allow queries with combined in and array-contains-any (#7142)
1 parent 963f14f commit 8da6951

File tree

5 files changed

+0
-222
lines changed

5 files changed

+0
-222
lines changed

packages/firestore/e2e/Query/where.and.filter.e2e.js

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -213,56 +213,6 @@ describe(' firestore().collection().where(AND Filters)', function () {
213213
}
214214
});
215215

216-
it('throws if query has array-contains-any & in filter', function () {
217-
try {
218-
firebase
219-
.firestore()
220-
.collection(COLLECTION)
221-
.where(
222-
Filter.and(Filter('foo.bar', 'array-contains-any', [1]), Filter('foo.bar', 'in', [2])),
223-
);
224-
225-
return Promise.reject(new Error('Did not throw an Error.'));
226-
} catch (error) {
227-
error.message.should.containEql(
228-
"You cannot use 'in' filters with 'array-contains-any' filters",
229-
);
230-
return Promise.resolve();
231-
}
232-
});
233-
234-
it('throws if query has multiple in filter', function () {
235-
try {
236-
firebase
237-
.firestore()
238-
.collection(COLLECTION)
239-
.where(Filter.and(Filter('foo.bar', 'in', [1]), Filter('foo.bar', 'in', [2])));
240-
241-
return Promise.reject(new Error('Did not throw an Error.'));
242-
} catch (error) {
243-
error.message.should.containEql("You cannot use more than one 'in' filter");
244-
return Promise.resolve();
245-
}
246-
});
247-
248-
it('throws if query has in & array-contains-any filter', function () {
249-
try {
250-
firebase
251-
.firestore()
252-
.collection(COLLECTION)
253-
.where(
254-
Filter.and(Filter('foo.bar', 'in', [1]), Filter('foo.bar', 'array-contains-any', [2])),
255-
);
256-
257-
return Promise.reject(new Error('Did not throw an Error.'));
258-
} catch (error) {
259-
error.message.should.containEql(
260-
"You cannot use 'array-contains-any' filters with 'in' filters",
261-
);
262-
return Promise.resolve();
263-
}
264-
});
265-
266216
it("should throw error when using 'not-in' operator twice", async function () {
267217
const ref = firebase.firestore().collection(COLLECTION);
268218

packages/firestore/e2e/Query/where.e2e.js

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -159,52 +159,6 @@ describe('firestore().collection().where()', function () {
159159
}
160160
});
161161

162-
it('throws if query has array-contains-any & in filter', function () {
163-
try {
164-
firebase
165-
.firestore()
166-
.collection(COLLECTION)
167-
.where('foo.bar', 'array-contains-any', [1])
168-
.where('foo.bar', 'in', [2]);
169-
return Promise.reject(new Error('Did not throw an Error.'));
170-
} catch (error) {
171-
error.message.should.containEql(
172-
"You cannot use 'in' filters with 'array-contains-any' filters",
173-
);
174-
return Promise.resolve();
175-
}
176-
});
177-
178-
it('throws if query has multiple in filter', function () {
179-
try {
180-
firebase
181-
.firestore()
182-
.collection(COLLECTION)
183-
.where('foo.bar', 'in', [1])
184-
.where('foo.bar', 'in', [2]);
185-
return Promise.reject(new Error('Did not throw an Error.'));
186-
} catch (error) {
187-
error.message.should.containEql("You cannot use more than one 'in' filter");
188-
return Promise.resolve();
189-
}
190-
});
191-
192-
it('throws if query has in & array-contains-any filter', function () {
193-
try {
194-
firebase
195-
.firestore()
196-
.collection(COLLECTION)
197-
.where('foo.bar', 'in', [1])
198-
.where('foo.bar', 'array-contains-any', [2]);
199-
return Promise.reject(new Error('Did not throw an Error.'));
200-
} catch (error) {
201-
error.message.should.containEql(
202-
"You cannot use 'array-contains-any' filters with 'in' filters",
203-
);
204-
return Promise.resolve();
205-
}
206-
});
207-
208162
/* Queries */
209163

210164
it('returns with where equal filter', async function () {

packages/firestore/e2e/Query/where.filter.e2e.js

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -171,55 +171,6 @@ describe('firestore().collection().where(Filters)', function () {
171171
}
172172
});
173173

174-
it('throws if query has array-contains-any & in filter', function () {
175-
try {
176-
firebase
177-
.firestore()
178-
.collection(COLLECTION)
179-
.where(Filter('foo.bar', 'array-contains-any', [1]))
180-
.where(Filter('foo.bar', 'in', [2]));
181-
182-
return Promise.reject(new Error('Did not throw an Error.'));
183-
} catch (error) {
184-
error.message.should.containEql(
185-
"You cannot use 'in' filters with 'array-contains-any' filters",
186-
);
187-
return Promise.resolve();
188-
}
189-
});
190-
191-
it('throws if query has multiple in filter', function () {
192-
try {
193-
firebase
194-
.firestore()
195-
.collection(COLLECTION)
196-
.where(Filter('foo.bar', 'in', [1]))
197-
.where(Filter('foo.bar', 'in', [2]));
198-
199-
return Promise.reject(new Error('Did not throw an Error.'));
200-
} catch (error) {
201-
error.message.should.containEql("You cannot use more than one 'in' filter");
202-
return Promise.resolve();
203-
}
204-
});
205-
206-
it('throws if query has in & array-contains-any filter', function () {
207-
try {
208-
firebase
209-
.firestore()
210-
.collection(COLLECTION)
211-
.where(Filter('foo.bar', 'in', [1]))
212-
.where(Filter('foo.bar', 'array-contains-any', [2]));
213-
214-
return Promise.reject(new Error('Did not throw an Error.'));
215-
} catch (error) {
216-
error.message.should.containEql(
217-
"You cannot use 'array-contains-any' filters with 'in' filters",
218-
);
219-
return Promise.resolve();
220-
}
221-
});
222-
223174
it("should throw error when using 'not-in' operator twice", async function () {
224175
const ref = firebase.firestore().collection(COLLECTION);
225176

packages/firestore/e2e/Query/where.or.filter.e2e.js

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -318,67 +318,6 @@ describe('firestore().collection().where(OR Filters)', function () {
318318
}
319319
});
320320

321-
it('throws if query has array-contains-any & in filter', function () {
322-
try {
323-
firebase
324-
.firestore()
325-
.collection(COLLECTION)
326-
.where(
327-
Filter.or(
328-
Filter.and(Filter('foo.bar', 'array-contains-any', [1]), Filter('foo.bar', 'in', [2])),
329-
Filter.and(Filter('foo.bar', 'array-contains-any', [1]), Filter('foo.bar', 'in', [2])),
330-
),
331-
);
332-
333-
return Promise.reject(new Error('Did not throw an Error.'));
334-
} catch (error) {
335-
error.message.should.containEql(
336-
"You cannot use 'in' filters with 'array-contains-any' filters",
337-
);
338-
return Promise.resolve();
339-
}
340-
});
341-
342-
it('throws if query has multiple in filter', function () {
343-
try {
344-
firebase
345-
.firestore()
346-
.collection(COLLECTION)
347-
.where(
348-
Filter.or(
349-
Filter.and(Filter('foo.bar', 'in', [1]), Filter('foo.bar', 'in', [2])),
350-
Filter.and(Filter('foo.bar', 'in', [1]), Filter('foo.bar', 'in', [2])),
351-
),
352-
);
353-
354-
return Promise.reject(new Error('Did not throw an Error.'));
355-
} catch (error) {
356-
error.message.should.containEql("You cannot use more than one 'in' filter");
357-
return Promise.resolve();
358-
}
359-
});
360-
361-
it('throws if query has in & array-contains-any filter', function () {
362-
try {
363-
firebase
364-
.firestore()
365-
.collection(COLLECTION)
366-
.where(
367-
Filter.or(
368-
Filter.and(Filter('foo.bar', 'in', [1]), Filter('foo.bar', 'array-contains-any', [2])),
369-
Filter.and(Filter('foo.bar', 'in', [1]), Filter('foo.bar', 'array-contains-any', [2])),
370-
),
371-
);
372-
373-
return Promise.reject(new Error('Did not throw an Error.'));
374-
} catch (error) {
375-
error.message.should.containEql(
376-
"You cannot use 'array-contains-any' filters with 'in' filters",
377-
);
378-
return Promise.resolve();
379-
}
380-
});
381-
382321
it("should throw error when using 'not-in' operator twice", async function () {
383322
const ref = firebase.firestore().collection(COLLECTION);
384323

packages/firestore/lib/FirestoreQueryModifiers.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,6 @@ export default class FirestoreQueryModifiers {
297297
);
298298
}
299299

300-
if (this.hasIn) {
301-
throw new Error(
302-
"Invalid query. You cannot use 'array-contains-any' filters with 'in' filters.",
303-
);
304-
}
305-
306300
if (this.hasNotIn) {
307301
throw new Error(
308302
"Invalid query. You cannot use 'array-contains-any' filters with 'not-in' filters.",
@@ -313,16 +307,6 @@ export default class FirestoreQueryModifiers {
313307
}
314308

315309
if (filter.operator === OPERATORS.in) {
316-
if (this.hasIn) {
317-
throw new Error("Invalid query. You cannot use more than one 'in' filter.");
318-
}
319-
320-
if (this.hasArrayContainsAny) {
321-
throw new Error(
322-
"Invalid query. You cannot use 'in' filters with 'array-contains-any' filters.",
323-
);
324-
}
325-
326310
if (this.hasNotIn) {
327311
throw new Error("Invalid query. You cannot use 'in' filters with 'not-in' filters.");
328312
}

0 commit comments

Comments
 (0)