-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix(zmodel): unique attribute validation issues #383
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
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds a centralized attribute-argument helper ( Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @ymc9's task —— View job Pull Request Review: fix(zmodel): unique attribute validation issuesI've completed my review of this PR. Here's my comprehensive feedback: Todo List:
🔍 Issue SummaryThis PR fixes a critical validation bug where 📋 Code Quality & Best Practices✅ Positive Aspects:
|
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.
Pull Request Overview
This PR adds support for using pre-existing database files in tests and refactors attribute argument handling to properly support named parameters instead of relying on positional arguments.
- Introduces a
dbFileoption tocreateTestClientallowing tests to use pre-populated SQLite database files - Refactors attribute argument access to use a new
getAttributeArghelper function that retrieves arguments by parameter name - Fixes a type guard logic issue in
getRecursiveBaseswhere parentheses were incorrectly placed
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/regression/test/v2-migrated/issue-2283/regression.test.ts | Adds regression test for issue 2283 using a pre-existing database file with complex nested queries |
| packages/testtools/src/client.ts | Implements dbFile option to copy and use pre-existing database files instead of creating new ones |
| packages/sdk/src/ts-schema-generator.ts | Updates to use getAttributeArg for retrieving the fields parameter by name instead of positional access |
| packages/language/src/validators/attribute-application-validator.ts | Updates constraint validation to use getAttributeArg for retrieving the fields parameter |
| packages/language/src/utils.ts | Adds getAttributeArg helper function and updates getAttributeArgLiteral signature; fixes type guard parentheses |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/language/src/validators/attribute-application-validator.ts
Outdated
Show resolved
Hide resolved
|
Claude finished @ymc9's task —— View job Pull Request Review: fix(zmodel): unique attribute validation issuesI've completed my review of this PR. Here's my comprehensive feedback: Todo List:
🔍 Issue SummaryThis PR fixes a critical validation bug where 📋 Code Quality & Best Practices✅ Positive Aspects:
|
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
🧹 Nitpick comments (1)
packages/testtools/src/client.ts (1)
111-117: Database file copying logic is correct.The implementation properly validates that
dbFileis only used with SQLite and copies the file to the working directory. The fail-fast behavior if the file doesn't exist is acceptable, though an explicit existence check with a clearer error message would be a minor UX improvement.If you want more explicit error handling:
// copy db file to workDir if specified if (options?.dbFile) { if (provider !== 'sqlite') { throw new Error('dbFile option is only supported for sqlite provider'); } + if (!fs.existsSync(options.dbFile)) { + throw new Error(`Database file not found: ${options.dbFile}`); + } fs.copyFileSync(options.dbFile, path.join(workDir, dbName)); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tests/regression/test/v2-migrated/issue-2283/dev.dbis excluded by!**/*.db
📒 Files selected for processing (3)
packages/language/src/validators/attribute-application-validator.ts(2 hunks)packages/testtools/src/client.ts(3 hunks)tests/regression/test/v2-migrated/issue-2283/.gitignore(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/testtools/src/client.ts (4)
packages/orm/src/client/options.ts (1)
ClientOptions(45-96)packages/common-helpers/src/tiny-invariant.ts (1)
invariant(4-14)packages/testtools/src/utils.ts (1)
loadDocumentWithPlugins(3-6)packages/cli/src/utils/exec-utils.ts (1)
execSync(6-15)
packages/language/src/validators/attribute-application-validator.ts (1)
packages/language/src/utils.ts (1)
getAttributeArg(325-330)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: claude-review
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: build-test (20.x, sqlite)
🔇 Additional comments (4)
tests/regression/test/v2-migrated/issue-2283/.gitignore (1)
1-1: LGTM!The gitignore exception correctly ensures that
.dbfiles in this test directory are tracked by Git, which is necessary for the regression test that uses a pre-existing database file with the newdbFileoption.packages/language/src/validators/attribute-application-validator.ts (1)
291-333: Improved attribute argument retrieval using centralized helper.The refactor to use
getAttributeArg(attr, 'fields')instead of direct array access is a solid improvement. Looking up arguments by parameter name rather than position is more maintainable and resilient to future changes in argument ordering.packages/testtools/src/client.ts (2)
124-154: Database creation flow correctly handles the dbFile option.The logic properly skips database creation and migration when
dbFileis provided, since the database already exists. The conditional flows forusePrismaPushand PostgreSQL database creation are correctly structured.
171-173: Schema push condition is correct.The logic properly skips schema push when either
usePrismaPush(Prisma already pushed the schema) ordbFile(schema already exists in the provided database) is specified. Schema push only occurs in the default flow where a new empty database needs to be initialized.
Summary by CodeRabbit
New Features
Improvements
Tests
Chores