feat(firestore): Add ifNull and coalesce expressions #9753
feat(firestore): Add ifNull and coalesce expressions #9753
ifNull and coalesce expressions #9753Conversation
🦋 Changeset detectedLatest commit: 2b30319 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 significantly enhances Firestore's data manipulation capabilities by introducing two new pipeline expressions: 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. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for new pipeline expressions, ifNull and coalesce, in Firebase Firestore and Firestore Lite. The changes include adding API definitions, implementing the expressions in the Expression class, updating documentation, and adding integration tests. Feedback from the review primarily focuses on documentation improvements, such as correcting capitalization inconsistencies, fixing formatting errors with [Expression] links, and ensuring descriptions accurately reflect that ifNull and coalesce handle both null and absent values.
I am having trouble creating individual review comments. Click here to see my feedback.
docs-devsite/firestore_lite_pipelines.expression.md (81)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with other descriptions in this file.
| [coalesce(replacement, others)](./firestore_lite_pipelines.expression.md#expressioncoalesce) | | <b><i>(Public Preview)</i></b> Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument. |
docs-devsite/firestore_lite_pipelines.expression.md (1513)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with standard documentation style.
Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument.
docs-devsite/firestore_lite_pipelines.expression.md (2599)
There's a formatting error in the documentation. The backslash before [Expression] should be removed to correctly render the link.
A new [Expression] representing the ifNull operation.
docs-devsite/firestore_lite_pipelines.expression.md (2633)
There's a formatting error in the documentation. The backslash before [Expression] should be removed to correctly render the link.
A new [Expression] representing the ifNull operation.
docs-devsite/firestore_lite_pipelines.md (95)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with other descriptions in this file.
| [coalesce(expression, replacement, others)](./firestore_lite_pipelines.md#coalesce_00859cb) | <b><i>(Public Preview)</i></b> Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument. |
docs-devsite/firestore_lite_pipelines.md (174)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with other descriptions in this file.
| [coalesce(fieldName, replacement, others)](./firestore_lite_pipelines.md#coalesce_249958e) | <b><i>(Public Preview)</i></b> Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument. |
docs-devsite/firestore_lite_pipelines.md (290-291)
The description for ifNull is incomplete. It should mention that it also checks for absent values, not just null values, to be consistent with the implementation and other parts of the documentation.
| [ifNull(ifExpr, elseExpr)](./firestore_lite_pipelines.md#ifnull_0e6d161) | <b><i>(Public Preview)</i></b> Creates an expression that returns the <code>elseExpr</code> argument if <code>ifExpr</code> is null or absent, else return the result of the <code>ifExpr</code> argument evaluation. |
| [ifNull(ifExpr, elseValue)](./firestore_lite_pipelines.md#ifnull_c34e5ed) | <b><i>(Public Preview)</i></b> Creates an expression that returns the <code>elseValue</code> argument if <code>ifExpr</code> is null or absent, else return the result of the <code>ifExpr</code> argument evaluation. |
docs-devsite/firestore_lite_pipelines.md (2637)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with standard documentation style.
Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument.
docs-devsite/firestore_lite_pipelines.md (9189)
The description for ifNull is incomplete. It should mention that it also checks for absent values, not just null values, to be consistent with the implementation.
Creates an expression that returns the `elseExpr` argument if `ifExpr` is null or absent, else return the result of the `ifExpr` argument evaluation.
docs-devsite/firestore_lite_pipelines.md (9236)
The description for the ifExpr parameter is inconsistent. It should state that it checks for "null or absence" to be accurate.
| ifExpr | [Expression](./firestore_lite_pipelines.expression.md#expression_class) | The expression to check for null or absence. |
docs-devsite/firestore_lite_pipelines.md (9243)
There's a formatting error in the documentation. The backslash before [Expression] should be removed to correctly render the link.
A new [Expression] representing the ifNull operation.
docs-devsite/firestore_lite_pipelines.md (9381)
There's a formatting error in the documentation. The backslash before [ifFieldName] should be removed to correctly render the link.
| elseValue | unknown | The value that will be returned if [ifFieldName] is null or absent. |
docs-devsite/firestore_pipelines.expression.md (81)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with other descriptions in this file.
| [coalesce(replacement, others)](./firestore_pipelines.expression.md#expressioncoalesce) | | <b><i>(Public Preview)</i></b> Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument. |
docs-devsite/firestore_pipelines.expression.md (1513)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with standard documentation style.
Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument.
docs-devsite/firestore_pipelines.expression.md (2599)
There's a formatting error in the documentation. The backslash before [Expression] should be removed to correctly render the link.
A new [Expression] representing the ifNull operation.
docs-devsite/firestore_pipelines.expression.md (2633)
There's a formatting error in the documentation. The backslash before [Expression] should be removed to correctly render the link.
A new [Expression] representing the ifNull operation.
docs-devsite/firestore_pipelines.md (95)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with other descriptions in this file.
| [coalesce(expression, replacement, others)](./firestore_pipelines.md#coalesce_00859cb) | <b><i>(Public Preview)</i></b> Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument. |
docs-devsite/firestore_pipelines.md (174)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with other descriptions in this file.
| [coalesce(fieldName, replacement, others)](./firestore_pipelines.md#coalesce_249958e) | <b><i>(Public Preview)</i></b> Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument. |
docs-devsite/firestore_pipelines.md (290-291)
The description for ifNull is incomplete. It should mention that it also checks for absent values, not just null values, to be consistent with the implementation and other parts of the documentation.
| [ifNull(ifExpr, elseExpr)](./firestore_pipelines.md#ifnull_0e6d161) | <b><i>(Public Preview)</i></b> Creates an expression that returns the <code>elseExpr</code> argument if <code>ifExpr</code> is null or absent, else return the result of the <code>ifExpr</code> argument evaluation. |
| [ifNull(ifExpr, elseValue)](./firestore_pipelines.md#ifnull_c34e5ed) | <b><i>(Public Preview)</i></b> Creates an expression that returns the <code>elseValue</code> argument if <code>ifExpr</code> is null or absent, else return the result of the <code>ifExpr</code> argument evaluation. |
docs-devsite/firestore_pipelines.md (2643)
There's a capitalization inconsistency in the description. "Returns" should be in lowercase to be consistent with standard documentation style.
Creates an expression that returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument.
docs-devsite/firestore_pipelines.md (9195)
The description for ifNull is incomplete. It should mention that it also checks for absent values, not just null values, to be consistent with the implementation.
Creates an expression that returns the `elseExpr` argument if `ifExpr` is null or absent, else return the result of the `ifExpr` argument evaluation.
docs-devsite/firestore_pipelines.md (9242)
The description for the ifExpr parameter is inconsistent. It should state that it checks for "null or absence" to be accurate.
| ifExpr | [Expression](./firestore_pipelines.expression.md#expression_class) | The expression to check for null or absence. |
docs-devsite/firestore_pipelines.md (9249)
There's a formatting error in the documentation. The backslash before [Expression] should be removed to correctly render the link.
A new [Expression] representing the ifNull operation.
docs-devsite/firestore_pipelines.md (9387)
There's a formatting error in the documentation. The backslash before [ifFieldName] should be removed to correctly render the link.
| elseValue | unknown | The value that will be returned if [ifFieldName] is null or absent. |
packages/firestore/src/lite-api/expressions.ts (3187)
There's a capitalization inconsistency in the JSDoc. "Returns" should be in lowercase to follow standard JSDoc conventions.
* Creates an expression that returns the first non-null, non-absent argument, without evaluating
packages/firestore/src/lite-api/expressions.ts (10600-10601)
The JSDoc for ifNull is incomplete. It should mention that it also checks for absent values, not just null values, to be consistent with the implementation.
* Creates an expression that returns the `elseExpr` argument if `ifExpr` is null or absent, else
* return the result of the `ifExpr` argument evaluation.
packages/firestore/src/lite-api/expressions.ts (10618-10619)
The JSDoc for ifNull is incomplete. It should mention that it also checks for absent values, not just null values, to be consistent with the implementation.
* Creates an expression that returns the `elseValue` argument if `ifExpr` is null or absent, else
* return the result of the `ifExpr` argument evaluation.
packages/firestore/src/lite-api/expressions.ts (10676)
There's a capitalization inconsistency in the JSDoc. "Returns" should be in lowercase to follow standard JSDoc conventions.
* Creates an expression that returns the first non-null, non-absent argument, without evaluating
packages/firestore/src/lite-api/expressions.ts (10699)
There's a capitalization inconsistency in the JSDoc. "Returns" should be in lowercase to follow standard JSDoc conventions.
* Creates an expression that returns the first non-null, non-absent argument, without evaluating
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for the ifNull and coalesce pipeline expressions in Firestore and Firestore Lite. The implementation includes adding these as static functions and instance methods on the Expression class, updating API review files, and providing comprehensive documentation and integration tests. The review feedback identifies minor documentation issues, such as rendering artifacts in markdown blockquotes and incomplete sentences that fail to properly contrast ifNull with ifAbsent.
|
Is CI failing because these are not yet in prod? https://github.com/firebase/firebase-js-sdk/actions/runs/23653752018/job/68906986246?pr=9753 |
dlarocque
left a comment
There was a problem hiding this comment.
LGTM after removing @beta tags.
| } | ||
|
|
||
| /** | ||
| * @beta |
There was a problem hiding this comment.
After #9772 these beta tags will be removed. Can you remove them from this PR?
Add support for
ifNullandcoalesce.