-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix: incorrect prisma query executed when count using a where filter involving a polymorphic base field #1586
Conversation
…involving a polymorphic base field
WalkthroughWalkthroughThe changes refactor the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- packages/runtime/src/enhancements/delegate.ts (10 hunks)
- tests/integration/tests/enhancements/with-delegate/enhanced-client.test.ts (2 hunks)
- tests/regression/tests/issue-1585.test.ts (1 hunks)
Additional comments not posted (17)
tests/regression/tests/issue-1585.test.ts (6)
1-1
: Import statement looks good.The import statement correctly imports the
loadSchema
function from@zenstackhq/testtools
.
2-2
: Describe block is well-defined.The describe block correctly names the test suite as 'issue 1585'.
3-3
: It block is well-defined.The it block correctly names the test case as 'regression'.
4-19
: Schema definition is correct.The schema definition includes the
Asset
andPost
models, with thePost
model extending theAsset
model. TheAsset
model includes the necessary fields and annotations.
21-23
: Database operations are correct.The database operations correctly create two
Post
entries with differentviews
values.
24-28
: Assertion is correct.The assertion correctly checks that the count of posts with
views
greater than 0 is 1.packages/runtime/src/enhancements/delegate.ts (7)
98-99
: Initial checks ininjectWhereHierarchy
method are correct.The initial checks correctly ensure that the
where
parameter is a plain object.
Line range hint
100-104
: Logical group handling ininjectWhereHierarchy
method is correct.The method correctly handles logical groups (
AND
,OR
,NOT
) by recursively callinginjectWhereHierarchy
.
Line range hint
105-112
: Field information resolution ininjectWhereHierarchy
method is correct.The method correctly resolves field information and handles fields that are data models by recursively calling
injectWhereHierarchy
.
Line range hint
113-134
: Base model handling ininjectWhereHierarchy
method is correct.The method correctly handles base models by preparing the base layer where clause and injecting the field value.
890-890
:aggregate
method correctly usesinjectWhereHierarchy
.The
aggregate
method correctly usesinjectWhereHierarchy
for thecursor
,orderBy
, andwhere
parameters.
894-894
:count
method correctly usesinjectWhereHierarchy
.The
count
method correctly usesinjectWhereHierarchy
for thecursor
andwhere
parameters.
958-958
:groupBy
method correctly usesinjectWhereHierarchy
.The
groupBy
method correctly usesinjectWhereHierarchy
for thewhere
parameter.tests/integration/tests/enhancements/with-delegate/enhanced-client.test.ts (4)
287-313
: LGTM! Verify the correctness of compound filter handling.The new test for reading with compound filters is well-structured and covers various scenarios. Ensure that the compound filter handling is correct and consistent across the codebase.
Verification successful
Verified: Compound filter handling is correctly implemented in the new test.
The new test for reading with compound filters is well-structured and covers various scenarios. The compound filters
AND
,OR
, andNOT
are correctly used and verified within the test.
tests/integration/tests/enhancements/with-delegate/enhanced-client.test.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of compound filter handling. # Test: Search for the usage of compound filters in the codebase. rg --type typescript -A 5 $'findMany({ where: { AND:'Length of output: 163
Script:
#!/bin/bash # Description: Verify the correctness of compound filter handling. # Test: Search for the usage of compound filters in the codebase. rg --type typescript -A 5 'findMany\(\{ where: \{ AND:'Length of output: 92
Script:
#!/bin/bash # Description: Verify the correctness of compound filter handling. # Test: Search for the usage of compound filters in the codebase. rg --type ts -A 5 'findMany\(\{ where: \{ AND:' rg --type ts -A 5 'findMany\(\{ where: \{ OR:' rg --type ts -A 5 'findMany\(\{ where: \{ NOT:'Length of output: 2627
Line range hint
350-366
:
LGTM! Verify the correctness of ordering by base fields handling.The new test for ordering by base fields is well-structured and covers various scenarios. Ensure that the ordering by base fields handling is correct and consistent across the codebase.
1080-1091
: LGTM! Verify the correctness of count handling with specific conditions.The new test for counting with specific conditions is well-structured and covers various scenarios. Ensure that the count handling with specific conditions is correct and consistent across the codebase.
Verification successful
Verified: The
count
method handles specific conditions correctly.The instances of the
count
method usage across the codebase confirm that the method handles various conditions consistently and correctly. The tests cover both successful and expected-to-fail scenarios, ensuring robust validation.
tests/integration/tests/enhancements/with-delegate/enhanced-client.test.ts
: Verified instances ofcount
with specific conditions.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of count handling with specific conditions. # Test: Search for the usage of count with specific conditions in the codebase. rg --type typescript -A 5 $'count({ select:'Length of output: 142
Script:
#!/bin/bash # Description: Verify the correctness of count handling with specific conditions. # Test: Search for the usage of count with specific conditions in the codebase. rg --type typescript -A 5 'count\(\{ select:'Length of output: 82
Script:
#!/bin/bash # Description: Verify the correctness of count handling with specific conditions. # Find all TypeScript files and search for the usage of count with specific conditions in those files. fd -e ts -x rg 'count\(\{ select:' -A 5Length of output: 259
Script:
#!/bin/bash # Description: Verify the correctness of count handling with specific conditions. # Find all TypeScript files and search for the usage of count with specific conditions in those files. fd -e ts -x rg 'count\(' -A 10Length of output: 11433
315-349
: LGTM! Verify the correctness of nested filter handling.The new test for reading with nested filters is well-structured and covers the scenario. Ensure that the nested filter handling is correct and consistent across the codebase.
Fixes #1585