Skip to content

Conversation

@lsmith77
Copy link
Contributor

@lsmith77 lsmith77 commented Feb 2, 2026

Note on the changes to the existing tests:

The type-checking tests contain duplicate configurations:

Outer config (required by createTestClient): Needed to instantiate the actual client. Without it, the new runtime validation throws an error before the test can run.

Inner config (in extraSourceFiles): Example code that demonstrates proper usage and ensures the generated TypeScript file compiles with correct type hints.

This duplication is a consequence of using createTestClient for type-checking. The outer config satisfies the runtime validation, while the inner config serves as realistic documentation of how users should structure their code.

Let me know if you would prefer adding a helper to side-step createTestClient for these cases.

Summary by CodeRabbit

  • Bug Fixes

    • ORM client now validates computed-field configurations at initialization and raises clear errors if any computed field is missing or misconfigured, preventing silent misconfiguration.
  • Tests

    • Added comprehensive end-to-end tests covering computed-field validation, error cases, and typed/runtime behaviors across various workflows.

Copilot AI review requested due to automatic review settings February 2, 2026 15:55
@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Added a private ClientImpl method that validates every computed field in the schema has a corresponding computedFields configuration; validation runs once during root client initialization. New end-to-end tests cover missing or invalid computed-field configurations and several computed-field workflows.

Changes

Cohort / File(s) Summary
Computed Field Validation
packages/orm/src/client/client-impl.ts
Added a private validateComputedFieldsConfig() and call it during root client initialization; it iterates models and their computed fields, throwing a configuration error for missing or non-function computedFields entries.
Validation Tests
tests/e2e/orm/client-api/computed-fields.test.ts
Added tests asserting errors for missing or invalid computed-field configurations; extended tests to provide computedFields in non-optional, optional, relation-read, and delegation scenarios and adjusted test scaffolding accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hop through code with eager eyes,
I check each computed field that lies.
No orphaned names shall roam tonight,
Each config found — all set upright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: adding runtime validation of computed field configuration at startup. It accurately summarizes the primary objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds runtime validation to ensure all @computed fields declared in the schema have corresponding computedFields implementations configured when the ORM client starts.

Changes:

  • Add startup-time validation in ClientImpl constructor to verify computed field config completeness.
  • Add E2E tests covering missing computed field configuration scenarios.
  • Update existing type-checking computed-field tests to include runtime computedFields config required by the new validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/e2e/orm/client-api/computed-fields.test.ts Adds new negative tests for missing computedFields config and updates type-checking cases to satisfy new startup validation.
packages/orm/src/client/client-impl.ts Introduces validateComputedFieldsConfig() and invokes it during client construction to fail fast on misconfiguration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lsmith77 lsmith77 force-pushed the validate-computed-fields branch from ffee7d2 to feaecb9 Compare February 2, 2026 16:06
@lsmith77 lsmith77 force-pushed the validate-computed-fields branch from feaecb9 to 1212adc Compare February 3, 2026 09:07
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.

2 participants