Skip to content

Commit 2ed795d

Browse files
liu-husongLiu Husong
authored andcommitted
fix(firestore): ensure limit(0) is properly serialized in query requests
Previously, calling .limit(0) on a Firestore Query did not serialize the zero value to the wire protocol, causing queries to be sent without a limit constraint. This change explicitly includes limit(0) in the query proto. Fixes #7382
1 parent 6ac6160 commit 2ed795d

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

handwritten/firestore/dev/test/query.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,23 @@ describe('limit() interface', () => {
19571957
query = query.limit(1).limit(2).limit(3);
19581958
await query.get();
19591959
});
1960+
1961+
// Regression test: This test currently fails because limit(0) is not
1962+
// serialized in the query proto (limit(0) is falsy in JavaScript).
1963+
// This test is expected to fail until the fix is applied.
1964+
it('handles limit(0) correctly', async () => {
1965+
const overrides: ApiOverride = {
1966+
runQuery: request => {
1967+
queryEquals(request, limit(0));
1968+
return emptyQueryStream();
1969+
},
1970+
};
1971+
1972+
firestore = await createInstance(overrides);
1973+
let query: Query = firestore.collection('collectionId');
1974+
query = query.limit(0);
1975+
await query.get();
1976+
});
19601977
});
19611978

19621979
describe('limitToLast() interface', () => {

0 commit comments

Comments
 (0)