Skip to content

test(firestore): update nested fields test to reflect backend change#9717

Merged
dlarocque merged 7 commits intomainfrom
dl/fix-nestedmod-test
Mar 31, 2026
Merged

test(firestore): update nested fields test to reflect backend change#9717
dlarocque merged 7 commits intomainfrom
dl/fix-nestedmod-test

Conversation

@dlarocque
Copy link
Copy Markdown
Contributor

The backend now supports nested field modification in the addFields and select changes. All aliases with a . are now treated as a nested field path. This change updates the tests to reflect this new behaviour.

This change is still in nightly. Do not merge until this is in prod.

The backend now supports nested field modification in the addFields and
select changes. All aliases with a `.` are now treated as a nested field
path. This change updates the tests to reflect this new behaviour.

This change is still in nightly. Do not merge until this is in prod.
@dlarocque dlarocque requested review from a team as code owners March 11, 2026 16:19
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 updates existing Firestore client-side tests to accommodate a new backend feature that reinterprets dot-notation field paths as nested object modifications. The changes ensure that the tests accurately reflect the expected behavior of the system once this backend capability is fully rolled out, preventing potential discrepancies and ensuring future compatibility.

Highlights

  • Backend Feature Alignment: Updated Firestore tests to reflect a new backend behavior where dot-notation field paths (e.g., 'awards.hugo') are now treated as nested field modifications (e.g., { awards: { hugo: true } }).
  • Test Data Structure Change: Modified test data within pipeline.test.ts files to use actual nested JavaScript objects for field paths, aligning with the backend's new interpretation.
  • Deployment Dependency: Noted that this change is dependent on a backend feature currently in nightly and should not be merged until that feature is deployed to production.

🧠 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.

Changelog
  • packages/firestore/test/integration/api/pipeline.test.ts
    • Updated test data to use nested objects for field paths in addFields and select operations.
  • packages/firestore/test/lite/pipeline.test.ts
    • Modified test data to use nested objects for field paths in addFields and select operations.
Activity
  • No human activity has been recorded on this pull request yet.
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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 11, 2026

⚠️ No Changeset found

Latest commit: 400c71c

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

Copy link
Copy Markdown
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 updates tests to reflect a backend change for nested fields. While the changes are mostly correct, there's an inconsistency in packages/firestore/test/integration/api/pipeline.test.ts where a test case was only partially updated. I've added a comment to address this.

Comment thread packages/firestore/test/integration/api/pipeline.test.ts
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 11, 2026

⚠️ No Changeset found

Latest commit: 5f48169

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

@dlarocque
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
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 updates tests to reflect a backend change that enables nested field modification using dot notation in aliases. The changes mostly involve updating aliases to avoid special characters and adjusting expected results to match the new nested object format.

I've found a logical inconsistency in one of the updated tests (test mapGet with field path) in both pipeline.test.ts files. The test attempts to access a nested field in two mutually exclusive ways, which makes the test invalid. I've left comments with details on how to fix it. The rest of the changes look good and improve test clarity.

Comment on lines 2898 to 2902
.select(
'title',
field('nested.level.1'),
mapGet('nested', 'level.1').mapGet('level.2').as('nested')
field('nestedField.level.1'),
mapGet('nestedField', 'level.1').mapGet('level.2').as('nested')
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This test appears to be logically inconsistent. The select statement attempts to access nested data in two conflicting ways:

  1. field('nestedField.level.1'): This treats nestedField as an object with a level property, which in turn has a 1 property. The expected data structure is { nestedField: { level: { '1': ... } } }.
  2. mapGet('nestedField', 'level.1'): This treats nestedField as a map with a key named 'level.1'. The expected data structure is { nestedField: { 'level.1': ... } }.

A single nestedField cannot have both of these structures. Please update the test to use a consistent way of accessing the nested data, which should also align with the structure of the test data. For example, if the intent is to test field(), you might want to change the mapGet() call to something like mapGet(mapGet('nestedField', 'level'), '1').

Comment on lines 2869 to 2873
.select(
'title',
field('nested.level.1'),
mapGet('nested', 'level.1').mapGet('level.2').as('nested')
field('nestedField.level.1'),
mapGet('nestedField', 'level.1').mapGet('level.2').as('nested')
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This test appears to be logically inconsistent. The select statement attempts to access nested data in two conflicting ways:

  1. field('nestedField.level.1'): This treats nestedField as an object with a level property, which in turn has a 1 property. The expected data structure is { nestedField: { level: { '1': ... } } }.
  2. mapGet('nestedField', 'level.1'): This treats nestedField as a map with a key named 'level.1'. The expected data structure is { nestedField: { 'level.1': ... } }.

A single nestedField cannot have both of these structures. Please update the test to use a consistent way of accessing the nested data, which should also align with the structure of the test data. For example, if the intent is to test field(), you might want to change the mapGet() call to something like mapGet(mapGet('nestedField', 'level'), '1').

Copy link
Copy Markdown
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.

Approve with requested changes. Thanks for getting these fixed

mapGet('nested', 'level.1').mapGet('level.2').as('nested')
field('nestedField.level.1'),
mapGet('nestedField', 'level.1').mapGet('level.2').as('nested')
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This appears to be changing the coverage of the test. What do you think about this instead:

      const snapshot = await execute(
        firestore
          .pipeline()
          .collection(randomCol.path)
          .limit(1)
          .replaceWith(
            map({
              title: 'foo',
              nested: {
                level: {
                  '1': 'bar'
                },
                'level.1': {
                  'level.2': 'baz'
                }
              }
            })
          )
          .select(
            'title',
            field('nested.level.1').as('`nested.level.1`'),
            mapGet('nested', 'level.1').mapGet('level.2').as('nested')
          )
      );

mapGet('nested', 'level.1').mapGet('level.2').as('nested')
field('nestedField.level.1'),
mapGet('nestedField', 'level.1').mapGet('level.2').as('nested')
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same comment as with standard SDK tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is intentional, to test the different ways to access nested fields within a doc

  • dot notation with field
  • dot notation with mapGet key
  • nested mapGet's

@dlarocque dlarocque merged commit 742e17a into main Mar 31, 2026
43 of 44 checks passed
@dlarocque dlarocque deleted the dl/fix-nestedmod-test branch March 31, 2026 14:20
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.

2 participants