Skip to content

Commit c576f87

Browse files
fix(firestore): increase amount of maximum disjunctions in firebase (#7543)
* Update FirestoreQuery.js * fix tests * fix array length * style(lint): `yarn lint:js` fixes I do not believe these were altered in the PR at all, perhaps a transitive dependency update altered the way lint likes things Either way, it's fully automated with regard to formatting checks and formatting, so here we are * test(firestore): adjust tests for 30 conjunction limit --------- Co-authored-by: Mike Hardy <[email protected]>
1 parent b1cee9a commit c576f87

File tree

5 files changed

+44
-53
lines changed

5 files changed

+44
-53
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,15 @@ describe(' firestore().collection().where(AND Filters)', function () {
176176
}
177177
});
178178

179-
it('throws if in query array length is greater than 10', function () {
179+
it('throws if in query array length is greater than 30', function () {
180180
try {
181+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
182+
181183
firebase
182184
.firestore()
183185
.collection(COLLECTION)
184186
.where(
185-
Filter.and(
186-
Filter('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
187-
Filter('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
188-
),
187+
Filter.and(Filter('foo.bar', 'in', queryArray), Filter('foo.bar', 'in', queryArray)),
189188
);
190189

191190
return Promise.reject(new Error('Did not throw an Error.'));
@@ -831,15 +830,14 @@ describe(' firestore().collection().where(AND Filters)', function () {
831830
}
832831
});
833832

834-
it('throws if in query array length is greater than 10', function () {
833+
it('throws if in query array length is greater than 30', function () {
835834
const { getFirestore, collection, query, and, where } = firestoreModular;
835+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
836+
836837
try {
837838
query(
838839
collection(getFirestore(), COLLECTION),
839-
and(
840-
where('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
841-
where('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
842-
),
840+
and(where('foo.bar', 'in', queryArray), where('foo.bar', 'in', queryArray)),
843841
);
844842

845843
return Promise.reject(new Error('Did not throw an Error.'));

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,14 @@ describe('firestore().collection().where()', function () {
138138
}
139139
});
140140

141-
it('throws if in query array length is greater than 10', function () {
141+
it('throws if in query array length is greater than 30', function () {
142142
try {
143-
firebase
144-
.firestore()
145-
.collection(COLLECTION)
146-
.where('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
143+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
144+
145+
firebase.firestore().collection(COLLECTION).where('foo.bar', 'in', queryArray);
147146
return Promise.reject(new Error('Did not throw an Error.'));
148147
} catch (error) {
149-
error.message.should.containEql('maximum of 10 elements in the value');
148+
error.message.should.containEql('maximum of 30 elements in the value');
150149
return Promise.resolve();
151150
}
152151
});
@@ -483,13 +482,14 @@ describe('firestore().collection().where()', function () {
483482

484483
it("should throw error when 'not-in' filter has a list of more than 10 items", async function () {
485484
const ref = firebase.firestore().collection(COLLECTION);
485+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
486486

487487
try {
488-
ref.where('test', 'not-in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
488+
ref.where('test', 'not-in', queryArray);
489489
return Promise.reject(new Error('Did not throw an Error.'));
490490
} catch (error) {
491491
error.message.should.containEql(
492-
'filters support a maximum of 10 elements in the value array.',
492+
'filters support a maximum of 30 elements in the value array.',
493493
);
494494
return Promise.resolve();
495495
}
@@ -708,16 +708,15 @@ describe('firestore().collection().where()', function () {
708708
}
709709
});
710710

711-
it('throws if in query array length is greater than 10', function () {
711+
it('throws if in query array length is greater than 30', function () {
712712
const { getFirestore, collection, query, where } = firestoreModular;
713+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
714+
713715
try {
714-
query(
715-
collection(getFirestore(), COLLECTION),
716-
where('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
717-
);
716+
query(collection(getFirestore(), COLLECTION), where('foo.bar', 'in', queryArray));
718717
return Promise.reject(new Error('Did not throw an Error.'));
719718
} catch (error) {
720-
error.message.should.containEql('maximum of 10 elements in the value');
719+
error.message.should.containEql('maximum of 30 elements in the value');
721720
return Promise.resolve();
722721
}
723722
});
@@ -1086,13 +1085,14 @@ describe('firestore().collection().where()', function () {
10861085
it("should throw error when 'not-in' filter has a list of more than 10 items", async function () {
10871086
const { getFirestore, collection, query, where } = firestoreModular;
10881087
const ref = collection(getFirestore(), COLLECTION);
1088+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
10891089

10901090
try {
1091-
query(ref, where('test', 'not-in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]));
1091+
query(ref, where('test', 'not-in', queryArray));
10921092
return Promise.reject(new Error('Did not throw an Error.'));
10931093
} catch (error) {
10941094
error.message.should.containEql(
1095-
'filters support a maximum of 10 elements in the value array.',
1095+
'filters support a maximum of 30 elements in the value array.',
10961096
);
10971097
return Promise.resolve();
10981098
}

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,18 @@ describe('firestore().collection().where(Filters)', function () {
157157
}
158158
});
159159

160-
it('throws if in query array length is greater than 10', function () {
160+
it('throws if in query array length is greater than 30', function () {
161161
try {
162+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
163+
162164
firebase
163165
.firestore()
164166
.collection(COLLECTION)
165-
.where(Filter('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]));
167+
.where(Filter('foo.bar', 'in', queryArray));
166168

167169
return Promise.reject(new Error('Did not throw an Error.'));
168170
} catch (error) {
169-
error.message.should.containEql('maximum of 10 elements in the value');
171+
error.message.should.containEql('maximum of 30 elements in the value');
170172
return Promise.resolve();
171173
}
172174
});
@@ -243,16 +245,15 @@ describe('firestore().collection().where(Filters)', function () {
243245

244246
it("should throw error when 'not-in' filter has a list of more than 10 items", async function () {
245247
const ref = firebase.firestore().collection(COLLECTION);
248+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
246249

247250
try {
248-
ref
249-
.where(Filter('foo.bar', '==', 1))
250-
.where(Filter('foo.bar', 'not-in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]));
251+
ref.where(Filter('foo.bar', '==', 1)).where(Filter('foo.bar', 'not-in', queryArray));
251252

252253
return Promise.reject(new Error('Did not throw an Error.'));
253254
} catch (error) {
254255
error.message.should.containEql(
255-
'filters support a maximum of 10 elements in the value array.',
256+
'filters support a maximum of 30 elements in the value array.',
256257
);
257258
return Promise.resolve();
258259
}

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -269,21 +269,17 @@ describe('firestore().collection().where(OR Filters)', function () {
269269
}
270270
});
271271

272-
it('throws if in query array length is greater than 10', function () {
272+
it('throws if in query array length is greater than 30', function () {
273273
try {
274+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
275+
274276
firebase
275277
.firestore()
276278
.collection(COLLECTION)
277279
.where(
278280
Filter.or(
279-
Filter.and(
280-
Filter('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
281-
Filter('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
282-
),
283-
Filter.and(
284-
Filter('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
285-
Filter('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
286-
),
281+
Filter.and(Filter('foo.bar', 'in', queryArray), Filter('foo.bar', 'in', queryArray)),
282+
Filter.and(Filter('foo.bar', 'in', queryArray), Filter('foo.bar', 'in', queryArray)),
287283
),
288284
);
289285

@@ -1326,20 +1322,16 @@ describe('firestore().collection().where(OR Filters)', function () {
13261322
}
13271323
});
13281324

1329-
it('throws if in query array length is greater than 10', function () {
1325+
it('throws if in query array length is greater than 30', function () {
13301326
const { getFirestore, collection, where, or, and, query } = firestoreModular;
1327+
const queryArray = Array.from({ length: 31 }, (_, i) => i + 1);
1328+
13311329
try {
13321330
query(
13331331
collection(getFirestore(), COLLECTION),
13341332
or(
1335-
and(
1336-
where('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
1337-
where('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
1338-
),
1339-
and(
1340-
where('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
1341-
where('foo.bar', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
1342-
),
1333+
and(where('foo.bar', 'in', queryArray), where('foo.bar', 'in', queryArray)),
1334+
and(where('foo.bar', 'in', queryArray), where('foo.bar', 'in', queryArray)),
13431335
),
13441336
);
13451337

packages/firestore/lib/FirestoreQuery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,9 @@ export default class FirestoreQuery {
471471
);
472472
}
473473

474-
if (value.length > 10) {
474+
if (value.length > 30) {
475475
throw new Error(
476-
`firebase.firestore().collection().where(_, _, *) 'value' is invalid. '${opStr}' filters support a maximum of 10 elements in the value array.`,
476+
`firebase.firestore().collection().where(_, _, *) 'value' is invalid. '${opStr}' filters support a maximum of 30 elements in the value array.`,
477477
);
478478
}
479479
}

0 commit comments

Comments
 (0)