-
Couldn't load subscription status.
- Fork 11
chore: update typing test #24
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
Conversation
WalkthroughA computed field named Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Suite
participant Client as ZenStackClient
participant UserModel as User Model
Test->>Client: Initialize with computed field postCount
Test->>Client: find({ where: { id } })
Client->>UserModel: Fetch user, compute postCount
UserModel-->>Client: Return user with postCount
Client-->>Test: Return result
Test->>Client: findMany({ select: { id: true } })
Client->>UserModel: Fetch users, omit postCount
UserModel-->>Client: Return users
Client-->>Test: Return result
Test->>Client: queryBuilder().from('User').select(['id', 'email']).where({ name })
Client->>UserModel: Build and execute query
UserModel-->>Client: Return selected fields
Client-->>Test: Return result
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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
🧹 Nitpick comments (3)
packages/runtime/test/typing/schema.ts (2)
6-6: Missing side-effect exclusion in generated import block
OperandExpressionis imported only for typing.
Adding/*#__NO_SIDE_EFFECTS__*/(or the equivalent banner your bundler recognises) prevents tree-shakers from thinking it has runtime side-effects.-import { type SchemaDef, type OperandExpression, ExpressionUtils } from "../../dist/schema"; +import { /*#__NO_SIDE_EFFECTS__*/ type SchemaDef, /*#__NO_SIDE_EFFECTS__*/ type OperandExpression, ExpressionUtils } from "../../dist/schema";
54-58: Redundantattributesarray entry
computed: truealready conveys the intent; keeping@computedinattributesis harmless but noisy in the generated JSON.
If your downstream tooling readscomputed: true, consider dropping the explicit attribute to keep the generated artefact minimal.packages/runtime/test/typing/verify-typing.ts (1)
549-559: Possible ambiguity in column names when using$qbWhen you select bare
'id'and'email'without qualifying them ('User.id'), the generated SQL may become ambiguous once joins are introduced later.- .select(['id', 'email']) + .select(['User.id', 'User.email'])This keeps the query future-proof if additional joins are appended.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/runtime/test/typing/schema.ts(2 hunks)packages/runtime/test/typing/typing-test.zmodel(1 hunks)packages/runtime/test/typing/verify-typing.ts(5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/runtime/test/typing/verify-typing.ts (2)
packages/runtime/src/client/client-impl.ts (1)
ZenStackClient(41-47)packages/runtime/test/typing/schema.ts (1)
schema(10-250)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build-test (20.x)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
packages/runtime/test/typing/typing-test.zmodel (1)
14-15:postCountcomputed field looks goodThe field is correctly marked
@computed, clearly signalling it won't be persisted.
No further concerns.packages/runtime/test/typing/schema.ts (1)
65-68:⚠️ Potential issueThrowing stub will explode at runtime if
computedFieldsoverride is forgotten
postCount()currently throws.
If someone instantiates the client without supplying the runtimecomputedFieldsoverride, any query that touchespostCountwill hard-fail.- postCount(): OperandExpression<number> { - throw new Error("This is a stub for computed field"); - } + /* Returns a dummy expression to satisfy typing; never executed at runtime */ + postCount(): OperandExpression<number> { + return ExpressionUtils.literal(0); + }Switching to
ExpressionUtils.literal(0)(or another innocuous expression) keeps type-safety without introducing a hidden runtime foot-gun.Likely an incorrect or invalid review comment.
packages/runtime/test/typing/verify-typing.ts (2)
4-14: Great use of runtimecomputedFieldsoverrideThe builder expression is concise and matches the schema definition. 👍
No issues spotted.
38-47: Solid negative-type testsThe extra
@ts-expect-errorlines correctly exercise the absence ofpostCountwhen omitted.
Nothing to change.
Summary by CodeRabbit
postCountto theUsermodel, allowing users to access the number of posts authored by a user.postCount.