-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
fix(zmodel): enum is resolved to wrong element after merging base models #1437
Conversation
Important Auto Review SkippedReview was skipped due to path filters Files ignored due to path filters (2)
You can disable this status message by setting the WalkthroughThis update primarily focuses on renaming and refactoring functions related to model merging and validation, enhancing compatibility across different modules by adjusting import paths, and introducing parameters to improve flexibility in model field retrieval. The changes streamline interactions between different components and modules, ensuring more robust and flexible schema handling. Changes
Possibly related issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Fixes #1435 |
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
tests/integration/tsconfig.json
is excluded by!**/*.json
Files selected for processing (8)
- packages/schema/src/cli/cli-util.ts (3 hunks)
- packages/schema/src/language-server/validator/datamodel-validator.ts (1 hunks)
- packages/schema/src/language-server/zmodel-code-action.ts (1 hunks)
- packages/schema/src/utils/ast-utils.ts (4 hunks)
- packages/schema/tests/utils.ts (3 hunks)
- packages/sdk/src/utils.ts (1 hunks)
- packages/testtools/src/model.ts (2 hunks)
- tests/regression/tests/issue-1435.test.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- packages/schema/tests/utils.ts
Additional comments not posted (12)
packages/testtools/src/model.ts (2)
Line range hint
8-56
: The implementation ofloadModel
function appears robust and well-structured, handling various error scenarios effectively.
Line range hint
56-67
: TheloadModelWithError
function correctly handles and categorizes errors from theloadModel
function, which is a good practice for robust error management.tests/regression/tests/issue-1435.test.ts (1)
1-119
: The test suite for issue 1435 is comprehensive and well-structured, covering complex model relationships and database interactions effectively.packages/schema/src/utils/ast-utils.ts (5)
Line range hint
50-85
: ThemergeBaseModels
function is well-implemented, efficiently handling the merging of base models with attention to details like abstract model handling and container index fixing.
Line range hint
84-104
: ThefilterBaseAttribute
function correctly implements attribute filtering based on well-defined criteria, ensuring that only appropriate attributes are inherited.
Line range hint
104-123
: ThecloneAst
function is effectively implemented, ensuring deep cloning of AST nodes with proper reference management and integration into the new context.
Line range hint
123-143
: ThegetIdFields
function is well-implemented, correctly handling the retrieval of both field-level and model-level ID attributes from data models.
Line range hint
143-148
: TheisAuthInvocation
function correctly identifies invocations of theauth
function in AST nodes, ensuring that the function is from the standard library.packages/schema/src/cli/cli-util.ts (2)
Line range hint
15-104
: TheloadDocument
function is well-implemented, effectively handling the loading and validation of ZModel documents, with comprehensive error management and support for plugins and imports.
Line range hint
116-134
: ThevalidationAfterImportMerge
function correctly implements additional validation checks on the model, ensuring the presence of a datasource and the correct number of@@auth
models.packages/sdk/src/utils.ts (2)
507-512
: The changes togetModelFieldsWithBases
look good and align with the new functionality described.Verification successful
The search results indicate that the function
getModelFieldsWithBases
is used extensively across various files in thepackages/schema
directory, as well as within its original file inpackages/sdk/src/utils.ts
. The usage of this function includes both the new signature with theincludeDelegate
parameter and calls where this parameter is not explicitly mentioned, which defaults totrue
due to the function definition.Observations:
- The function is imported and used in several files related to language server and validator functionalities within the
schema
package.- The function is called with and without the optional
includeDelegate
parameter, demonstrating flexibility and backward compatibility of the function's new signature.Conclusion:
The integration of the
getModelFieldsWithBases
function with the new optional parameter appears to be successful and is being utilized appropriately across the system. The usage aligns with the intended enhancements described in the original review comment.Actionable Directive:
- Ensure that all developers are aware of the new optional parameter and its default behavior to avoid any confusion or misuse in future developments.
Locations in the codebase that need attention:
packages/schema/src/utils/ast-utils.ts
packages/schema/src/language-server/zmodel-code-action.ts
packages/schema/src/language-server/zmodel-scope.ts
packages/schema/src/language-server/zmodel-linker.ts
packages/schema/src/language-server/validator/datamodel-validator.ts
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify integration of `getModelFieldsWithBases` with other parts of the system. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type typescript $'getModelFieldsWithBases'Length of output: 81
Script:
#!/bin/bash # Description: Verify integration of `getModelFieldsWithBases` with other parts of the system. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type ts $'getModelFieldsWithBases'Length of output: 2219
515-524
: The updates togetRecursiveBases
function correctly implement the newincludeDelegate
parameter, enhancing flexibility.
No description provided.