Skip to content

Conversation

@wu-hui
Copy link
Contributor

@wu-hui wu-hui commented Jan 9, 2026

No description provided.

@wu-hui wu-hui requested review from a team as code owners January 9, 2026 17:18
@changeset-bot
Copy link

changeset-bot bot commented Jan 9, 2026

⚠️ No Changeset found

Latest commit: 245b3e1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @wu-hui, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the Firestore query-to-pipeline conversion process by eliminating undesired exists() conditions. The change ensures that queries using != and not-in operators, as well as implicitly ordered queries, no longer automatically filter out documents where the queried field is absent. This leads to more accurate and intuitive query results, particularly for sparse data, and is thoroughly verified by new integration tests.

Highlights

  • Query Conversion Logic Refinement: Removed implicit exists() conditions for != (not equal) and not-in operators during query-to-pipeline conversion, ensuring that documents with missing fields are not unintentionally excluded.
  • Explicit Order By Existence Filters: Modified the generation of existence conditions for orderBy clauses to only apply when an orderBy is explicitly defined in the query, rather than for implicitly added orderings.
  • New Integration Tests: Added comprehensive integration tests to validate the updated behavior of existence filters for not-in, not-equal, inequality operators, and explicit orderBy clauses.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly removes the undesired exists() conditions from the query-to-pipeline conversion for != and not-in operators. The changes in pipeline-util.ts align the behavior with Firestore's query semantics, and the new integration tests in query_to_pipeline.test.ts effectively verify this. However, I've identified a critical issue where one of the changes could lead to a runtime error for queries without an explicit orderBy clause.

Comment on lines +169 to 171
const existsConditions = query.explicitOrderBy.map(order =>
field(order.field.canonicalString()).exists()
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This change to use query.explicitOrderBy is correct for the PR's goal. However, it can result in existsConditions being an empty array, which exposes a bug in the subsequent logic (lines 172-182). When existsConditions is empty, pipeline.where(existsConditions[0]) is called with undefined, causing a runtime error for any query without an explicit orderBy.

To prevent this, please add a check to ensure existsConditions is not empty before attempting to add a where clause.

Here's a suggested fix:

  if (existsConditions.length > 0) {
    const condition =
      existsConditions.length === 1
        ? existsConditions[0]
        : and(
            existsConditions[0],
            existsConditions[1],
            ...existsConditions.slice(2)
          );
    pipeline = pipeline.where(condition);
  }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree. Line 180 below should be else if (existsConditions.length > 0) ...

@google-oss-bot
Copy link
Collaborator

Size Report 1

Affected Products

  • @firebase/firestore-lite-pipelines

    TypeBase (f044045)Merge (27c810d)Diff
    browser112 kB112 kB-48 B (-0.0%)
    main212 kB212 kB-85 B (-0.0%)
    module112 kB112 kB-48 B (-0.0%)
    react-native112 kB112 kB-48 B (-0.0%)
  • @firebase/firestore-pipelines

    TypeBase (f044045)Merge (27c810d)Diff
    browser205 kB205 kB-48 B (-0.0%)
    main631 kB631 kB-85 B (-0.0%)
    module205 kB205 kB-48 B (-0.0%)
    react-native205 kB205 kB-48 B (-0.0%)
  • bundle

    TypeBase (f044045)Merge (27c810d)Diff
    firestore (Pipeline Query with lt filter (execute))246 kB246 kB-44 B (-0.0%)
    firestore (Pipeline Query with lt filter (useFirestorePipelines))171 kB171 kB-44 B (-0.0%)
    firestore (Pipeline Query with lt plus and function)171 kB171 kB-44 B (-0.0%)
  • firebase

    TypeBase (f044045)Merge (27c810d)Diff
    firebase-firestore-lite-pipelines.js124 kB124 kB-48 B (-0.0%)
    firebase-firestore-pipelines.js506 kB506 kB-48 B (-0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/CHc4fOUqVq.html

@google-oss-bot
Copy link
Collaborator

Copy link
Contributor

@MarkDuckworth MarkDuckworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with small request for change

Comment on lines +169 to 171
const existsConditions = query.explicitOrderBy.map(order =>
field(order.field.canonicalString()).exists()
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree. Line 180 below should be else if (existsConditions.length > 0) ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants