-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: index-spec matching for optional values and vectorConfig. #9003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The few new optional values for indexes were added recently via #8939. When comparing the local index with the server index, the default value of optional index configurations should be taken into account depending on the database edition (standard or enterprise). I also found that the matching logic for vectorConfig was not working correctly, so I fixed that as well. Fixes #8859.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @ehsannas, 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 index comparison logic within the Firebase CLI. The primary goal is to ensure accurate matching between locally defined index specifications and indexes existing on the server, particularly for recently introduced optional configurations and vector index settings. The changes address how default values for optional index properties like apiScope
, density
, and multikey
are handled based on the database edition, and fixes a bug in comparing vectorConfig
objects. This leads to more reliable index deployment and management by preventing unnecessary index recreation or deletion due to comparison discrepancies.
Highlights
- Enhanced Index Matching for Optional Values: The core index matching logic (
indexMatchesSpec
) has been significantly improved to correctly handle optional index configurations such asapiScope
,density
, andmultikey
. This fix ensures that when comparing local index specifications with existing server-side indexes, the appropriate default values for these optional fields are considered based on the database's edition (Standard or Enterprise). - Accurate Vector Configuration Comparison: The comparison for
vectorConfig
within index fields was previously flawed, using a strict equality check that failed for objects. This has been corrected to use a deep equality comparison, ensuring thatvectorConfig
objects are accurately matched. - Introduction of Optional Value Comparison Helpers: New helper functions (
optionalValueMatches
,optionalApiScopeMatches
,optionalDensityMatches
,optionalMultikeyMatches
) have been introduced to encapsulate the logic for comparing optional index fields, making theindexMatchesSpec
method cleaner and more robust. - Explicit Handling of Unsupported 'unique' Index Configuration: The
unique
index configuration, recently added but not yet fully supported, is now explicitly disallowed during index validation. Attempting to define aunique
index will now result in aFirebaseError
, preventing unsupported configurations from being deployed. - Improved Index Display in Pretty-Print: The pretty-printing utility for Firestore indexes has been updated to include
density
andmultikey
properties in the output, providing more comprehensive and readable information about deployed indexes.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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
-
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. ↩
There was a problem hiding this 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 effectively addresses issues with index specification matching. It correctly handles optional values like apiScope
, density
, and multikey
by considering their default values, which now properly account for the database edition. The fix for vectorConfig
matching, which now uses a deep equality check, is a crucial improvement. The accompanying tests have been significantly enhanced and refactored, providing robust coverage for the new logic. My review includes a couple of minor suggestions to improve code quality by adding explicit return types and correcting JSDoc comments in the new helper functions, which will enhance clarity and maintainability.
/gemini review |
There was a problem hiding this 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 effectively addresses the index specification matching for optional values by considering their defaults based on the database edition. The fix for vectorConfig
comparison using deep equality is a crucial correction. The test suite has been significantly improved, providing robust coverage for these changes. I have a couple of minor suggestions to enhance code clarity by adding explicit return types to new helper functions. Overall, this is a solid and well-tested improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a changelog, and this LGTM other than nits
multikey: true, | ||
fields: [], | ||
}; | ||
describe("Density", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: love how thorough you were with these tests. Probably not worth it to refactor for this PR, but I am a fan of table style tests (https://g3doc.corp.google.com/go/g3doc/style/decisions.md?cl=head#table-driven-tests) - it's more of a Go idiom, but it leads to some really nice deduplication of code.
The few new optional values for indexes were added recently via #8939.
When comparing the local index with the server index, the default value of optional index configurations should be taken into account depending on the database edition (standard or enterprise).
I also found that the matching logic for vectorConfig was not working correctly, so I fixed that as well.
Fixes #8859.