fix(orm): _count is not included in select clause's typing when querying from a to-one relation#2403
fix(orm): _count is not included in select clause's typing when querying from a to-one relation#2403
Conversation
…ing from a to-one relation #2343
|
Claude finished @ymc9's task —— View job Code ReviewTodo List:
SummaryThis PR fixes a TypeScript typing issue where AnalysisThe Problem: The The Solution: Changed Code Quality Assessment✅ Strengths:
✅ TypeScript Safety:
✅ Test Quality:
Potential Concerns
Performance Considerations
Security Assessment
Recommendation✅ APPROVE - This is a well-executed fix that:
The fix properly enables |
📝 WalkthroughWalkthroughThe PR updates the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/orm/client-api/find.test.ts (1)
1140-1143: Use_count: trueinstead of_count: {}for a precise guard test.
{}is unconditionally invalid forSelectCount(boolean | { select: {...} }), so the@ts-expect-errorhere would never become stale — even ifCommentlater gains a to-many relation, the error would persist for the wrong reason, masking aHasToManyRelationsguard regression._count: trueis valid exactly when_countis present in the type, which is the right sentinel.The existing analogous test on line 1021 already uses
_count: true; this should match that pattern. Also consider adding an inline description to the@ts-expect-errorcomment for consistency with line 1020.♻️ Proposed fix
client.comment.findMany({ - // `@ts-expect-error` - select: { _count: {} }, + // `@ts-expect-error` Comment has no to-many relations to count + select: { _count: true }, });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/e2e/orm/client-api/find.test.ts` around lines 1140 - 1143, The test uses an invalid sentinel select `{ _count: {} }` which will always be a type error; update the call to client.comment.findMany to use `_count: true` instead (so the `@ts-expect-error` detects presence/absence of _count correctly) and add an inline description to the `@ts-expect-error` comment (matching the style on line 1020) to clarify the expected guard (refer to client.comment.findMany, SelectCount, Comment and HasToManyRelations in the test).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/e2e/orm/client-api/find.test.ts`:
- Around line 1140-1143: The test uses an invalid sentinel select `{ _count: {}
}` which will always be a type error; update the call to client.comment.findMany
to use `_count: true` instead (so the `@ts-expect-error` detects
presence/absence of _count correctly) and add an inline description to the
`@ts-expect-error` comment (matching the style on line 1020) to clarify the
expected guard (refer to client.comment.findMany, SelectCount, Comment and
HasToManyRelations in the test).
#2343
Summary by CodeRabbit
Bug Fixes
Tests