fix(better-auth): support custom table enum field types and defaults#621
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. 📝 WalkthroughWalkthroughSchema generator now accepts enum-like field types (string arrays) and string/number defaults; adds tests for CLI generate/check and two auth fixtures; updates the better-auth package.json with a test script and devDependency adjustments. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 Code Review Complete ✅I've completed my review of PR #621 which fixes issue #592 for better-auth adapter support of custom table enum field types and defaults. Todo List:
SummaryThis PR enhances the better-auth adapter's schema generator to support:
Code Quality Assessment✅ Positive Aspects
|
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #592 by adding support for custom table enum field types and default values in the ZenStack better-auth adapter. The issue occurred when better-auth's schema generator encountered enum-like field types (arrays of literal strings) which were not previously supported.
Changes:
- Added enum type handling to map array and comma-separated enum types to String type in the schema generator
- Added support for string and number default values in addition to existing boolean support
- Added test suite to verify schema generation with custom field types and defaults
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/auth-adapters/better-auth/src/schema-generator.ts | Adds enum type detection and handling in getMappedFieldType, adds createNumberAttributeArg and createStringAttributeArg functions, imports NumberLiteral type |
| packages/auth-adapters/better-auth/test/cli-generate.test.ts | New test file that generates schemas via CLI and verifies correctness |
| packages/auth-adapters/better-auth/test/auth.ts | Simple auth configuration for basic test case |
| packages/auth-adapters/better-auth/test/auth-custom.ts | Custom auth configuration with enum fields and various default value types |
| packages/auth-adapters/better-auth/package.json | Adds test script and test dependencies (@better-auth/cli, tmp, @types/tmp, @zenstackhq/cli) |
| pnpm-lock.yaml | Updates lock file with new dependencies and their transitive dependencies |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Claude finished @ymc9's task —— View job Code Review Complete ✅I've completed my review of PR #621 which fixes issue #592 for better-auth adapter support of custom table enum field types and defaults. Todo List:
SummaryThis PR enhances the better-auth adapter's schema generator to support:
Code Quality Assessment✅ Positive Aspects
|
|
Claude finished @ymc9's task —— View job Code Review Complete ✅I've completed my review of PR #621 which fixes issue #592 for better-auth adapter support of custom table enum field types and defaults. Todo List:
SummaryThis PR enhances the better-auth adapter's schema generator to support:
Code Quality Assessment✅ Positive Aspects
|
fixes #592
Summary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.