Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion handwritten/firestore/dev/src/reference/query-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export class QueryUtil<
// call to `requestStream()` will backoff should the restart
// fail before delivering any results.
let newQuery: Query<AppModelType, DbModelType>;
if (!this._queryOptions.limit) {
if (this._queryOptions.limit === undefined) {
Comment thread
dlarocque marked this conversation as resolved.
newQuery = query;
} else {
const newLimit =
Expand Down
2 changes: 1 addition & 1 deletion handwritten/firestore/dev/src/reference/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ export class Query<
structuredQuery.startAt = this.toCursor(this._queryOptions.startAt);
structuredQuery.endAt = this.toCursor(this._queryOptions.endAt);

if (this._queryOptions.limit) {
if (this._queryOptions.limit !== undefined) {
Comment thread
dlarocque marked this conversation as resolved.
structuredQuery.limit = {value: this._queryOptions.limit};
}

Expand Down
14 changes: 14 additions & 0 deletions handwritten/firestore/dev/test/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,20 @@ describe('limit() interface', () => {
query = query.limit(1).limit(2).limit(3);
await query.get();
});

it('handles limit(0) correctly', async () => {
const overrides: ApiOverride = {
runQuery: request => {
queryEquals(request, limit(0));
return emptyQueryStream();
},
};

firestore = await createInstance(overrides);
let query: Query = firestore.collection('collectionId');
query = query.limit(0);
await query.get();
});
});

describe('limitToLast() interface', () => {
Expand Down
Loading