fix(orm): typing issue with relation fields with fk having default value#371
fix(orm): typing issue with relation fields with fk having default value#371
Conversation
WalkthroughThis PR introduces relation-level default detection to the schema system. It adds a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (7)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-10-21T16:09:31.218ZApplied to files:
🧬 Code graph analysis (3)tests/e2e/orm/client-api/default-auth.test.ts (2)
packages/sdk/src/ts-schema-generator.ts (1)
tests/e2e/orm/schemas/default-auth/schema.ts (2)
⏰ 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)
🔇 Additional comments (10)
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 ✅Reviewing PR #371: "fix(orm): typing issue with relation fields with fk having default value" Todo List:
Review SummaryThis PR successfully addresses a TypeScript typing issue with relation fields that have foreign keys with default values. The implementation is well-structured and comprehensive. Key Changes Analyzed1. Core Schema Enhancement (
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for relation fields with default foreign key values, specifically enabling the auth().id function to be used as a default value for foreign key fields. This allows creating related entities without explicitly providing the foreign key value when it can be inferred from the authentication context.
- Added
hasDefaultproperty to relation metadata when all foreign key fields have default values - Updated type system to recognize relation fields with defaults as having default values
- Added schema and test files demonstrating auth-based default values in relations
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/orm/schemas/default-auth/schema.zmodel | New test schema defining User/Profile/Address models with auth-based FK default |
| tests/e2e/orm/schemas/default-auth/schema.ts | Generated TypeScript schema with hasDefault metadata for Profile.user relation |
| tests/e2e/orm/schemas/default-auth/models.ts | Generated TypeScript model type exports |
| tests/e2e/orm/schemas/default-auth/input.ts | Generated TypeScript input type definitions for the test schema |
| tests/e2e/orm/client-api/default-auth.test.ts | Test verifying profile creation without explicit userId when using auth default |
| packages/sdk/src/ts-schema-generator.ts | Logic to detect and mark relations with all FK fields having defaults |
| packages/schema/src/schema.ts | Type system updates to recognize relations with hasDefault as having defaults |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary by CodeRabbit