test(firestore): update nested fields test to reflect backend change#9717
test(firestore): update nested fields test to reflect backend change#9717
Conversation
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.
Summary of ChangesHello, 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
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
|
There was a problem hiding this comment.
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.
|
|
/gemini review |
There was a problem hiding this comment.
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.
| .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') | ||
| ) |
There was a problem hiding this comment.
This test appears to be logically inconsistent. The select statement attempts to access nested data in two conflicting ways:
field('nestedField.level.1'): This treatsnestedFieldas an object with alevelproperty, which in turn has a1property. The expected data structure is{ nestedField: { level: { '1': ... } } }.mapGet('nestedField', 'level.1'): This treatsnestedFieldas 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').
| .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') | ||
| ) |
There was a problem hiding this comment.
This test appears to be logically inconsistent. The select statement attempts to access nested data in two conflicting ways:
field('nestedField.level.1'): This treatsnestedFieldas an object with alevelproperty, which in turn has a1property. The expected data structure is{ nestedField: { level: { '1': ... } } }.mapGet('nestedField', 'level.1'): This treatsnestedFieldas 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').
MarkDuckworth
left a comment
There was a problem hiding this comment.
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') | ||
| ) |
There was a problem hiding this comment.
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') | ||
| ) |
There was a problem hiding this comment.
Same comment as with standard SDK tests
There was a problem hiding this comment.
This is intentional, to test the different ways to access nested fields within a doc
- dot notation with
field - dot notation with
mapGetkey - nested
mapGet's
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.