fix(orm): incorrect result type when "_count" is nested inside "include"#589
Conversation
📝 WalkthroughWalkthroughThe PR extends the ModelResult type definition to conditionally augment results with a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~14 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (2)tests/e2e/**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
tests/**/type*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (6)📓 Common learnings📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-11-26T01:55:04.540ZApplied to files:
📚 Learning: 2025-12-30T15:07:06.254ZApplied to files:
🧬 Code graph analysis (1)tests/e2e/orm/client-api/find.test.ts (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). (4)
🔇 Additional comments (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 Code Review Complete ✅Reviewing PR #589: fix(orm): incorrect result type when "_count" is nested inside "include" Todo List:
SummaryThis PR addresses a type inference issue when using Code Review Feedback✅ Code Quality & Best PracticesStrengths:
Type System Changes in } & ('_count' extends keyof I
? I['_count'] extends false | undefined
? {}
: { _count: SelectCountResult<Schema, Model, I['_count']> }
: {})This properly handles the ✅ Test CoverageExcellent test additions:
Test scenarios covered:
✅ Security & Performance
✅ Potential Issues AnalysisNo significant issues found:
✅ Architecture Consistency
Recommendations✅ Ready to MergeThis is a well-implemented fix that:
Minor Suggestions
ConclusionThis is a solid, minimal fix that addresses the type inference issue for |
There was a problem hiding this comment.
Pull request overview
This PR fixes a TypeScript typing issue where the _count property was not properly typed when nested inside an include clause. The runtime already supported this functionality, but the type definitions were incomplete, leading to type errors when accessing the _count property.
Changes:
- Added conditional type support for
_countinincludeclauses to theModelResulttype - Added runtime tests to verify
_countworks correctly withincludein multiple scenarios - Added type-checking tests to ensure TypeScript correctly infers types for
_countininclude
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/orm/src/client/crud-types.ts | Extended the ModelResult type to properly type the _count property when it appears in include clauses |
| tests/e2e/orm/client-api/find.test.ts | Added comprehensive runtime tests for _count inside include with select syntax, boolean true, and filtered counts |
| tests/e2e/orm/schemas/typing/typecheck.ts | Added type-checking tests to verify TypeScript correctly infers types for _count usage in include |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary by CodeRabbit
New Features
_countwithin include queries. Retrieve aggregate counts alongside related data in a single operation.✏️ Tip: You can customize this high-level summary in your review settings.