Skip to content

Commit 85a0726

Browse files
Validate that at least one argument is provided for Cursor (#433)
1 parent d14bb5e commit 85a0726

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

handwritten/firestore/dev/src/reference.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,9 +1355,9 @@ export class Query {
13551355
*/
13561356
startAt(...fieldValuesOrDocumentSnapshot: Array<DocumentSnapshot|UserInput>):
13571357
Query {
1358-
const options = extend(true, {}, this._queryOptions);
1358+
this._validator.minNumberOfArguments('startAt', arguments, 1);
13591359

1360-
fieldValuesOrDocumentSnapshot = [].slice.call(arguments);
1360+
const options = extend(true, {}, this._queryOptions);
13611361

13621362
const fieldOrders =
13631363
this.createImplicitOrderBy(fieldValuesOrDocumentSnapshot);
@@ -1390,9 +1390,9 @@ export class Query {
13901390
*/
13911391
startAfter(...fieldValuesOrDocumentSnapshot:
13921392
Array<DocumentSnapshot|UserInput>): Query {
1393-
const options = extend(true, {}, this._queryOptions);
1393+
this._validator.minNumberOfArguments('startAfter', arguments, 1);
13941394

1395-
fieldValuesOrDocumentSnapshot = [].slice.call(arguments);
1395+
const options = extend(true, {}, this._queryOptions);
13961396

13971397
const fieldOrders =
13981398
this.createImplicitOrderBy(fieldValuesOrDocumentSnapshot);
@@ -1424,9 +1424,9 @@ export class Query {
14241424
*/
14251425
endBefore(...fieldValuesOrDocumentSnapshot:
14261426
Array<DocumentSnapshot|UserInput>): Query {
1427-
const options = extend(true, {}, this._queryOptions);
1427+
this._validator.minNumberOfArguments('endBefore', arguments, 1);
14281428

1429-
fieldValuesOrDocumentSnapshot = [].slice.call(arguments);
1429+
const options = extend(true, {}, this._queryOptions);
14301430

14311431
const fieldOrders =
14321432
this.createImplicitOrderBy(fieldValuesOrDocumentSnapshot);
@@ -1458,9 +1458,9 @@ export class Query {
14581458
*/
14591459
endAt(...fieldValuesOrDocumentSnapshot: Array<DocumentSnapshot|UserInput>):
14601460
Query {
1461-
const options = extend(true, {}, this._queryOptions);
1461+
this._validator.minNumberOfArguments('endAt', arguments, 1);
14621462

1463-
fieldValuesOrDocumentSnapshot = [].slice.call(arguments);
1463+
const options = extend(true, {}, this._queryOptions);
14641464

14651465
const fieldOrders =
14661466
this.createImplicitOrderBy(fieldValuesOrDocumentSnapshot);

handwritten/firestore/dev/test/query.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,14 @@ describe('startAt() interface', () => {
12281228
/Only a direct child can be used as a query boundary. Found: 'coll\/doc\/coll\/doc\/coll'./);
12291229
});
12301230

1231+
it('requires at least one value', () => {
1232+
const query = firestore.collection('coll/doc/coll');
1233+
1234+
expect(() => {
1235+
query.startAt();
1236+
}).to.throw(/Function 'startAt\(\)' requires at least 1 argument./);
1237+
});
1238+
12311239
it('can specify document snapshot', () => {
12321240
const overrides = {
12331241
runQuery: (request) => {

0 commit comments

Comments
 (0)