Skip to content

@computed fields from mixin types (with) cause column does not exist error when the model is explicitly included#2539

Open
lsmith77 wants to merge 1 commit intozenstackhq:devfrom
lsmith77:computed-field-nested-include.test
Open

@computed fields from mixin types (with) cause column does not exist error when the model is explicitly included#2539
lsmith77 wants to merge 1 commit intozenstackhq:devfrom
lsmith77:computed-field-nested-include.test

Conversation

@lsmith77
Copy link
Copy Markdown
Contributor

@lsmith77 lsmith77 commented Mar 31, 2026

failing test to illustrate #2540

Summary by CodeRabbit

  • Tests
    • Added an end-to-end test ensuring computed fields inherited from a mixin are correctly populated on related records returned via nested includes, validating both direct queries and parent queries that include child relations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

📝 Walkthrough

Walkthrough

Adds a new Vitest end-to-end test that verifies a computed field inherited via a mixin (with) is correctly populated for a child model when that model is returned as a nested relation using include on its parent.

Changes

Cohort / File(s) Summary
Computed Field Nested Include Test
tests/e2e/orm/client-api/computed-field-nested-include.test.ts
Adds an e2e test defining ParentRelated mixin with parentCode computed via a correlated subquery, Parent and Child models, creates sample data, and asserts Child.parentCode is present both in direct child queries and when returned via Parent with include: { children: true }.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐰 I hopped through queries, subquery-light,
Mixins gave fields that shone so bright,
Parent codes found where children hide,
Included with care, side by side,
Tests now dance — a bunny's delight! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the core issue being tested: computed fields from mixin types causing errors when models are explicitly included in queries.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/e2e/orm/client-api/computed-field-nested-include.test.ts (1)

60-60: Prefer typed validation over as any to maintain type-safety in this regression test.

Line 60 suppresses compiler checks that could catch future API/schema drift. The options object should use satisfies to validate against the function signature while preserving flexibility with string schemas:

♻️ Suggested refactor
-            } as any,
+            } satisfies Parameters<typeof createTestClient>[1],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/orm/client-api/computed-field-nested-include.test.ts` at line 60,
The test currently uses an unsafe cast ("as any") for the options object;
replace that cast with TypeScript's "satisfies" operator to validate the object
against the real API parameter type (for example the parameter type of the
client function under test, e.g. Parameters<typeof <clientFunction>>[0] or the
exported options type from the API), so the literal keeps flexible string-schema
values but still gets compile-time validation; locate the options object in
computed-field-nested-include.test.ts and change the "as any" to a "satisfies
<expected parameter type>" check (import or reference the appropriate
function/type used by 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/computed-field-nested-include.test.ts`:
- Line 60: The test currently uses an unsafe cast ("as any") for the options
object; replace that cast with TypeScript's "satisfies" operator to validate the
object against the real API parameter type (for example the parameter type of
the client function under test, e.g. Parameters<typeof <clientFunction>>[0] or
the exported options type from the API), so the literal keeps flexible
string-schema values but still gets compile-time validation; locate the options
object in computed-field-nested-include.test.ts and change the "as any" to a
"satisfies <expected parameter type>" check (import or reference the appropriate
function/type used by the test).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3260908e-0086-4ab1-91a3-d57d0a4b7523

📥 Commits

Reviewing files that changed from the base of the PR and between 80f364a and 9e94d09.

📒 Files selected for processing (1)
  • tests/e2e/orm/client-api/computed-field-nested-include.test.ts

@lsmith77 lsmith77 force-pushed the computed-field-nested-include.test branch from 9e94d09 to 2abea97 Compare April 1, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant