-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix(cli): error generating TS schema when default value is negative number #417
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
WalkthroughIntroduces a helper to generate negative numeric literals as unary prefix expressions while leaving non-negative numbers as plain numeric literals; adds a regression test asserting a negative default value (-6) is applied when creating a model instance. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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 PR Review AnalysisReviewing the pull request for issue #393 - negative number default values in TS schema generation. Review Tasks:
SummaryThis is a well-implemented fix for a TypeScript AST generation bug where negative number literals in default values weren't properly handled. Code Quality ✅Problem Identified:
Solution Applied:
Implementation Quality ✅The fix is:
Test Coverage ✅Good regression test coverage:
Suggestion for improvement:
Performance ✅No performance concerns - the fix is a simple conditional check with minimal overhead. Security ✅No security implications. This is purely a code generation fix for TypeScript AST creation. Architecture ✅The fix properly maintains separation of concerns by keeping number literal creation logic encapsulated in its own method. Minor Suggestions
Verdict: APPROVED ✅This is a clean, targeted fix that addresses the specific issue without introducing risk. The test coverage ensures the fix works correctly and prevents regression. |
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 fixes issue #393 where the TypeScript schema generator incorrectly handled negative numbers in default values. The fix properly generates negative numeric literals using TypeScript AST's prefix unary expression instead of directly passing negative numbers to createNumericLiteral.
- Created
createNumberLiteralhelper method to handle negative numbers by creating a prefix unary expression with a minus token - Added regression test to verify that models with negative default values (e.g.,
@default(-6)) can be successfully generated and used
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/regression/test/issue-393.test.ts |
Added regression test that verifies schema generation and database operations work correctly with negative default values |
packages/sdk/src/ts-schema-generator.ts |
Refactored numeric literal creation to handle negative numbers using TypeScript AST's createPrefixUnaryExpression with MinusToken |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Claude finished @ymc9's task —— View job PR Review AnalysisReviewing the pull request for issue #393 - negative number default values in TS schema generation. Review Tasks:
SummaryThis is a well-implemented fix for a TypeScript AST generation bug where negative number literals in default values weren't properly handled. Code Quality ✅Problem Identified:
Solution Applied:
Implementation Quality ✅The fix is:
Test Coverage ✅Good regression test coverage:
Suggestion for improvement:
Performance ✅No performance concerns - the fix is a simple conditional check with minimal overhead. Security ✅No security implications. This is purely a code generation fix for TypeScript AST creation. Architecture ✅The fix properly maintains separation of concerns by keeping number literal creation logic encapsulated in its own method. Minor Suggestions
Verdict: APPROVED ✅This is a clean, targeted fix that addresses the specific issue without introducing risk. The test coverage ensures the fix works correctly and prevents regression. |
fixes #393
Summary by CodeRabbit
Bug Fixes
Tests