-
-
Notifications
You must be signed in to change notification settings - Fork 122
fix(zmodel): check optionality consistency between relation and fk fields #1053
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
WalkthroughWalkthroughThe changes involve improvements to the datamodel validator in a schema language server, focusing on better handling of scalar types, spelling corrections in error messages, and adding validation for optional fields in non-optional relations. Additionally, there are updates to integration tests, including the removal of a logging option and the introduction of a new test case to address a specific regression scenario related to model relationships and field optionality. Changes
Assessment against linked 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 (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (3)
- packages/schema/src/language-server/validator/datamodel-validator.ts (4 hunks)
- tests/integration/tests/regression/issue-1014.test.ts (1 hunks)
- tests/integration/tests/regression/issue-177.test.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- tests/integration/tests/regression/issue-1014.test.ts
Additional comments: 5
tests/integration/tests/regression/issue-177.test.ts (1)
- 1-27: The test case is well-structured and targets the specific regression scenario outlined in issue #177 effectively. It checks that the schema validation logic correctly identifies and reports inconsistencies in field optionality within model relationships. The use of
loadModelWithError
to simulate the loading of a model with an expected error message is a good approach to validate the updated validation logic. The test is clear, concise, and directly related to the issue it aims to prevent regressions for.packages/schema/src/language-server/validator/datamodel-validator.ts (4)
- 67-67: The update to the comparison for
SCALAR_TYPES.includes
to handle the type correctly is a crucial improvement. It ensures that the validation logic accurately identifies scalar types, which is essential for the integrity of the schema validation process. This change enhances the robustness of the type checking mechanism within the validator.- 124-124: Correcting spelling errors in error messages, such as
"fields" value cannot be empty
, improves the clarity and professionalism of the feedback provided to users during schema validation. This change contributes to better user experience by making error messages more understandable.- 134-134: Similar to the previous comment, correcting spelling errors in error messages, such as
"references" value cannot be empty
, enhances the clarity and professionalism of the feedback provided to users. Clear and accurate error messages are crucial for effective debugging and schema correction by users.- 160-167: The addition of validation for optional fields in non-optional relations is a significant improvement. This validation ensures that the schema validator can accurately identify and report inconsistencies in optionality between related fields. It directly addresses the issue outlined in #177, enhancing the robustness and correctness of Prisma schema definitions. This change is a proactive approach to maintaining the integrity of schema relationships and preventing potential runtime issues.
Fixes #177
Summary by CodeRabbit