Skip to content

Conversation

@liu-husong
Copy link

Description

Opening this PR to sense check if this can be worked on to get merged. This PR fixes #2461 where the Firestore SDK doesn't seem to apply the limit clause when limit(0) is given.

Impact

The change should allow the Firestore SDK to handle limit(0) properly, i.e., returning an empty array as expected.

Testing

Unit test added. But I'm not familiar with the codebase so I'm not sure if that alone is sufficient.

Additional Information

Checklist

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease
  • Appropriate docs were updated
  • Appropriate comments were added, particularly in complex areas or places that require background
  • No new warnings or issues will be generated from this change

Fixes #2461 🦕

Previously, calling `.limit(0)` on a Firestore Query did not correctly serialize the zero value to the underlying wire protocol. This caused queries intended to return zero results to be sent without a limit constraint, potentially returning unintended results.

This commit fixes the serialization logic so that `limit(0)` is now explicitly included in the query proto. Also adds/updates related unit tests to validate the correct handling of limit-zero queries.
@liu-husong liu-husong requested review from a team as code owners December 19, 2025 15:22
@google-cla
Copy link

google-cla bot commented Dec 19, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@product-auto-label product-auto-label bot added size: s Pull request size is small. api: firestore Issues related to the googleapis/nodejs-firestore API. labels Dec 19, 2025
@liu-husong liu-husong changed the title [draft] [draft] Fix Firestore SDK not limiting results when given limit(0) Dec 19, 2025
@liu-husong liu-husong marked this pull request as draft December 19, 2025 15:24
@liu-husong liu-husong changed the title [draft] Fix Firestore SDK not limiting results when given limit(0) Fix Firestore SDK not limiting results when given limit(0) Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the googleapis/nodejs-firestore API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firestore client library's limit API not handling limit(0) correctly

1 participant