Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Jan 11, 2026

Summary by CodeRabbit

  • Chores

    • Bumped all package versions to 3.2.1.
  • New Features

    • Added support for counting related records when including nested data selections.
    • Enhanced JSON field default value handling with support for null defaults and array types.
  • Bug Fixes

    • Improved update operations to use identifier-based filtering for read-back queries.
    • Fixed issues with JSON array fields in mutation operations.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 11, 2026 09:50
@coderabbitai
Copy link

coderabbitai bot commented Jan 11, 2026

📝 Walkthrough

Walkthrough

This PR bumps package versions from 3.2.0 to 3.2.1 across the monorepo and introduces targeted functional improvements: refactored attribute parameter validation with discriminated union errors and JSON default handling, conditional _count field typing in ORM queries, refined read-back filtering in update operations, explicit null default handling in schema generation, and new regression tests for _count and JSON validation scenarios.

Changes

Cohort / File(s) Summary
Version Bumps (3.2.0 → 3.2.1)
package.json, packages/auth-adapters/better-auth/package.json, packages/cli/package.json, packages/clients/client-helpers/package.json, packages/clients/tanstack-query/package.json, packages/common-helpers/package.json, packages/config/eslint-config/package.json, packages/config/typescript-config/package.json, packages/config/vitest-config/package.json, packages/create-zenstack/package.json, packages/ide/vscode/package.json, packages/language/package.json, packages/orm/package.json, packages/plugins/policy/package.json, packages/schema/package.json, packages/sdk/package.json, packages/server/package.json, packages/testtools/package.json, packages/zod/package.json, samples/orm/package.json, tests/e2e/package.json, tests/regression/package.json, tests/runtimes/bun/package.json, tests/runtimes/edge-runtime/package.json
Consistent version update across entire monorepo; no behavioral changes.
Language Attribute Validation
packages/language/src/validators/attribute-application-validator.ts
Refactored assignableToAttributeParam() to return discriminated union { result: true } | { result: false; error: string } instead of boolean; introduced JSON default validation logic with isLiteralJsonString() helper; enhanced error propagation for attribute parameter type compatibility.
ORM Type System
packages/orm/src/client/crud-types.ts
Extended ModelResult<...> type to conditionally include _count field when _count is selected in include branch; added conditional type logic: '_count' extends keyof I ? ... : {}.
ORM Update Read-Back
packages/orm/src/client/crud/operations/update.ts
Refined read-back query to use only identifier fields derived from updateResult via getIdValues() instead of full result or original where filter; tightens filtering scope.
SDK Schema Generator
packages/sdk/src/ts-schema-generator.ts
Added explicit null default value handling using _null expression; updated getFieldMappedDefault() and getMappedValue() return types to include null; added isNullExpr() check in value mapping.
ORM _count Functional Tests
tests/e2e/orm/client-api/find.test.ts
Added test block verifying _count behavior inside include with three scenarios: _count with nested select, with boolean true, and with filtered relations.
ORM _count Type Tests
tests/e2e/orm/schemas/typing/typecheck.ts
Extended TypeScript type-check coverage for _count inside include; added console logs verifying typed access to includeWithCount?._count.posts and similar paths.
Import Reordering
tests/e2e/orm/policy/crud/update.test.ts
Reordered imports to move vitest import before @zenstackhq/testtools; no behavioral changes.
Regression Tests: JSON Validation
tests/regression/test/issue-584.test.ts
New test file validating JSON and JSON array default value handling; verifies rejection of non-literal defaults and acceptance of valid JSON string literals and arrays.
Regression Tests: JSON Array Update
tests/regression/test/issue-586.test.ts
New test file verifying no read-back error when updating JsonArrayField with nested JsonArray and mutation plugin; covers PostgreSQL provider scenario.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • Issue #570: The conditional _count field augmentation in ModelResult directly addresses the missing _count typings in include branches.

Possibly related PRs

  • PR #589: Modifies the same ModelResult type in crud-types.ts to conditionally add _count for include branches.
  • PR #585: Modifies the same update read-back filtering logic in update.ts to use ID-only filters derived from update results.
  • PR #588: Modifies attribute-application-validator.ts with the same discriminated union return type and JSON-default validation refactoring.

Poem

🐰 A rabbit's verse on version three-two-one:
From 3.2.0 we hop and bound,
With JSON counts and nulls so sound,
Type-safe schemas, read-backs refined—
A tidy patch, validation redesigned! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly indicates a version bump from 3.2.0 to 3.2.1 and reflects the primary objective of merging dev to main, which aligns with the changeset's composition of version bumps across all package.json files and targeted bug fixes.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@claude
Copy link

claude bot commented Jan 11, 2026

Claude finished @ymc9's task —— View job


Code Review for v3.2.1 Release

Reviewing the dev -> main merge for version 3.2.1. I've analyzed the changes across 33 files focusing on code quality, potential bugs, performance, security, and test coverage.

Review Tasks:

  • Analyze version consistency across all package.json files
  • Review core functionality changes in language package
  • Review ORM package changes and type safety
  • Review SDK changes and code generation
  • Analyze new regression tests for completeness
  • Check for security concerns
  • Assess performance implications
  • Provide comprehensive feedback summary

🔍 Review Summary

This PR represents a clean v3.2.1 release containing important bug fixes and improvements. The changes are well-structured and follow good engineering practices.

Positive Findings

Version Management:

  • ✅ All 27 package.json files consistently updated to v3.2.1
  • ✅ Clean version bump with no inconsistencies

Bug Fixes & Improvements:

Code Quality:

  • ✅ Enhanced attribute validation with better error messages in attribute-application-validator.ts:419-448
  • ✅ Improved type safety in CRUD operations with proper result type handling
  • ✅ Well-structured TypeScript code generation with proper conditional imports
  • ✅ Comprehensive test coverage for regression cases

Testing:

⚠️ Minor Observations

Performance Considerations:

  • The SDK changes include conditional imports for ExpressionUtils which is good for bundle size
  • Update operations now use id-only filters for read-back, improving query efficiency

Type Safety:

  • Enhanced attribute parameter validation provides better compile-time safety
  • CRUD type improvements ensure more accurate TypeScript inference

🔐 Security Assessment

  • ✅ No security vulnerabilities identified
  • ✅ Input validation improvements enhance security posture
  • ✅ JSON validation prevents injection through malformed default values

📊 Test Coverage Assessment

The regression tests are comprehensive:

🎯 Recommendation

✅ APPROVE - This is a high-quality release with:

  • Important bug fixes for JSON handling and type safety
  • Comprehensive test coverage
  • Clean code with no security concerns
  • Consistent versioning across all packages

The changes are focused, well-tested, and address real user issues without introducing breaking changes.

Copy link

@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.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0996b4 and 154ba29.

📒 Files selected for processing (33)
  • package.json
  • packages/auth-adapters/better-auth/package.json
  • packages/cli/package.json
  • packages/clients/client-helpers/package.json
  • packages/clients/tanstack-query/package.json
  • packages/common-helpers/package.json
  • packages/config/eslint-config/package.json
  • packages/config/typescript-config/package.json
  • packages/config/vitest-config/package.json
  • packages/create-zenstack/package.json
  • packages/ide/vscode/package.json
  • packages/language/package.json
  • packages/language/src/validators/attribute-application-validator.ts
  • packages/orm/package.json
  • packages/orm/src/client/crud-types.ts
  • packages/orm/src/client/crud/operations/update.ts
  • packages/plugins/policy/package.json
  • packages/schema/package.json
  • packages/sdk/package.json
  • packages/sdk/src/ts-schema-generator.ts
  • packages/server/package.json
  • packages/testtools/package.json
  • packages/zod/package.json
  • samples/orm/package.json
  • tests/e2e/orm/client-api/find.test.ts
  • tests/e2e/orm/policy/crud/update.test.ts
  • tests/e2e/orm/schemas/typing/typecheck.ts
  • tests/e2e/package.json
  • tests/regression/package.json
  • tests/regression/test/issue-584.test.ts
  • tests/regression/test/issue-586.test.ts
  • tests/runtimes/bun/package.json
  • tests/runtimes/edge-runtime/package.json
🧰 Additional context used
📓 Path-based instructions (2)
tests/e2e/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

E2E tests should validate real-world schema compatibility with established projects

Files:

  • tests/e2e/orm/policy/crud/update.test.ts
  • tests/e2e/orm/client-api/find.test.ts
  • tests/e2e/orm/schemas/typing/typecheck.ts
tests/**/type*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Ensure TypeScript inference and type coverage are validated through type coverage tests

Files:

  • tests/e2e/orm/schemas/typing/typecheck.ts
🧠 Learnings (11)
📚 Learning: 2025-12-30T15:07:10.092Z
Learnt from: mwillbanks
Repo: zenstackhq/zenstack-v3 PR: 550
File: packages/orm/src/client/crud/operations/base.ts:158-159
Timestamp: 2025-12-30T15:07:10.092Z
Learning: In the zenstackhq/zenstack-v3 codebase, ts-expect-error should be heavily avoided in production code (packages/*). It is acceptable in test files but production code should use proper type annotations, type assertions, or refactoring to resolve type errors instead.

Applied to files:

  • packages/clients/tanstack-query/package.json
  • packages/common-helpers/package.json
  • package.json
  • packages/zod/package.json
  • packages/config/eslint-config/package.json
  • packages/config/typescript-config/package.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization

Applied to files:

  • samples/orm/package.json
  • packages/orm/src/client/crud-types.ts
  • tests/e2e/orm/policy/crud/update.test.ts
  • packages/orm/src/client/crud/operations/update.ts
  • tests/e2e/orm/client-api/find.test.ts
  • packages/orm/package.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : ZModel schema files should define database structure and policies that compile to TypeScript via `zenstack generate`

Applied to files:

  • packages/schema/package.json
  • packages/language/package.json
  • packages/zod/package.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/e2e/**/*.{ts,tsx} : E2E tests should validate real-world schema compatibility with established projects

Applied to files:

  • tests/regression/test/issue-584.test.ts
  • tests/regression/test/issue-586.test.ts
  • tests/e2e/orm/policy/crud/update.test.ts
  • tests/e2e/orm/client-api/find.test.ts
  • tests/e2e/orm/schemas/typing/typecheck.ts
  • tests/e2e/package.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests

Applied to files:

  • tests/regression/test/issue-584.test.ts
  • tests/regression/test/issue-586.test.ts
  • packages/orm/src/client/crud-types.ts
  • tests/e2e/orm/policy/crud/update.test.ts
  • tests/e2e/orm/client-api/find.test.ts
  • tests/e2e/orm/schemas/typing/typecheck.ts
  • packages/orm/package.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/**/type*.{ts,tsx} : Ensure TypeScript inference and type coverage are validated through type coverage tests

Applied to files:

  • tests/regression/test/issue-584.test.ts
  • tests/e2e/orm/schemas/typing/typecheck.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible

Applied to files:

  • packages/orm/src/client/crud-types.ts
  • tests/e2e/orm/policy/crud/update.test.ts
  • packages/orm/package.json
📚 Learning: 2025-12-30T15:07:06.254Z
Learnt from: mwillbanks
Repo: zenstackhq/zenstack-v3 PR: 550
File: packages/orm/src/client/crud/operations/base.ts:158-159
Timestamp: 2025-12-30T15:07:06.254Z
Learning: Do not use ts-expect-error in production code within the zenstackhq/zenstack-v3 repo (e.g., packages/*). Use explicit type annotations, targeted type assertions, or refactor to resolve the type error. ts-expect-error may be acceptable only in test files for stubbing or temporary silencing. Ensure production code is type-safe and maintainable.

Applied to files:

  • packages/orm/src/client/crud-types.ts
  • packages/orm/src/client/crud/operations/update.ts
  • packages/sdk/src/ts-schema-generator.ts
  • packages/language/src/validators/attribute-application-validator.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/cli/**/*.test.{ts,tsx} : CLI package tests should focus on action-specific tests for each command

Applied to files:

  • tests/e2e/orm/policy/crud/update.test.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Use `pnpm` with workspaces for package management, pinned to version `pnpm10.12.1`

Applied to files:

  • package.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to ide/vscode/**/{package.json,version.ts} : The VSCode IDE extension package should maintain a different version from other packages to comply with VSCode Marketplace requirements

Applied to files:

  • packages/ide/vscode/package.json
  • packages/config/typescript-config/package.json
🧬 Code graph analysis (5)
tests/regression/test/issue-584.test.ts (1)
packages/testtools/src/client.ts (1)
  • createTestClient (101-248)
tests/regression/test/issue-586.test.ts (1)
packages/testtools/src/client.ts (1)
  • createPolicyTestClient (258-269)
packages/orm/src/client/crud/operations/update.ts (1)
packages/orm/src/client/query-utils.ts (1)
  • getIdValues (181-187)
tests/e2e/orm/client-api/find.test.ts (1)
tests/e2e/orm/client-api/utils.ts (2)
  • createUser (6-21)
  • createPosts (23-32)
packages/sdk/src/ts-schema-generator.ts (1)
packages/language/src/generated/ast.ts (1)
  • isNullExpr (593-595)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Agent
  • GitHub Check: build-test (22.x, postgresql)
  • GitHub Check: build-test (22.x, sqlite)
  • GitHub Check: claude-review
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (33)
packages/config/eslint-config/package.json (1)

3-3: Version bump is consistent with the coordinated release.

The version update from 3.2.0 to 3.2.1 aligns with the PR objective and other package version updates in the monorepo.

packages/testtools/package.json (1)

3-3: Version bump is consistent with the coordinated release.

The version update from 3.2.0 to 3.2.1 aligns with the PR objective and other package version updates in the monorepo. Dependencies remain unchanged.

samples/orm/package.json (1)

3-3: Version bump is consistent with the coordinated release.

The version update from 3.2.0 to 3.2.1 aligns with the PR objective and other package version updates in the monorepo.

packages/server/package.json (1)

3-3: Version bump is appropriate.

Patch version update from 3.2.0 to 3.2.1 with no dependency changes. Dependency versions remain stable across the board.

tests/e2e/package.json (1)

3-3: Version bump aligns with monorepo release.

Patch version update with no test infrastructure or dependency changes. Workspace dependencies will automatically reference updated versions.

packages/ide/vscode/package.json (1)

4-4: No action needed—VSCode extension versioning is correct.

The VSCode extension maintains synchronized versioning with the rest of the monorepo (3.2.1), which is the current and appropriate approach. No separate versioning mechanism exists, and the standard VSCode Extension CLI (vsce) is used for publishing without requiring custom version handling. The zenstack-v3 extension is properly configured as a separate extension on the VSCode Marketplace for ZenStack v3.x, coexisting alongside the original extension for v2.x.

Likely an incorrect or invalid review comment.

packages/plugins/policy/package.json (1)

3-3: VSCode IDE extension requires separate versioning; do not use 3.2.1 for packages/ide/vscode/package.json.

The other package.json files correctly bump to 3.2.1, but packages/ide/vscode/package.json must maintain a separate version to comply with VSCode Marketplace requirements. Per the codebase guidelines, the VSCode IDE extension should not align with the monorepo's standard versioning scheme. Update packages/ide/vscode/package.json to use its own version number (e.g., a separate sequence) and verify compatibility with VSCode Marketplace release processes before merging.

⛔ Skipped due to learnings
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to ide/vscode/**/{package.json,version.ts} : The VSCode IDE extension package should maintain a different version from other packages to comply with VSCode Marketplace requirements
packages/orm/package.json (1)

3-3: LGTM: Version bump aligns with the patch release.

The version increment from 3.2.0 to 3.2.1 is appropriate for this patch release merge to main.

packages/auth-adapters/better-auth/package.json (1)

3-3: LGTM: Version bump aligns with the patch release.

The version increment from 3.2.0 to 3.2.1 is consistent with the monorepo-wide version update.

package.json (1)

3-3: LGTM: Root package version bump for v3.2.1 release.

The version increment correctly reflects the patch release being merged from dev to main.

packages/clients/tanstack-query/package.json (1)

3-3: LGTM: Version bump aligns with the patch release.

The version increment from 3.2.0 to 3.2.1 maintains consistency across the monorepo packages.

packages/sdk/package.json (1)

3-3: LGTM: Version bump aligns with the patch release.

The version increment from 3.2.0 to 3.2.1 is consistent with the v3.2.1 release objectives.

packages/language/package.json (1)

4-4: Version bump to 3.2.1 looks consistent with the release PR.

packages/common-helpers/package.json (1)

3-3: LGTM: version bumped to 3.2.1 only.

tests/runtimes/bun/package.json (1)

3-3: LGTM: bun-e2e version bumped to 3.2.1 (no other changes).

tests/regression/package.json (1)

3-3: LGTM: regression package version bumped to 3.2.1 only.

tests/runtimes/edge-runtime/package.json (1)

3-3: LGTM: edge-runtime-e2e version bumped to 3.2.1 (no other changes).

packages/zod/package.json (1)

3-3: LGTM: Version bump is consistent with the release.

The version increment from 3.2.0 to 3.2.1 aligns with the PR objectives for the v3.2.1 release.

packages/config/typescript-config/package.json (1)

3-3: LGTM: Version bump is consistent with the release.

The version increment from 3.2.0 to 3.2.1 aligns with the PR objectives for the v3.2.1 release.

packages/schema/package.json (1)

3-3: LGTM: Version bump is consistent with the release.

The version increment from 3.2.0 to 3.2.1 aligns with the PR objectives for the v3.2.1 release.

packages/cli/package.json (1)

6-6: LGTM: Version bump is consistent with the release.

The version increment from 3.2.0 to 3.2.1 aligns with the PR objectives for the v3.2.1 release.

packages/config/vitest-config/package.json (1)

4-4: LGTM! Clean version bump.

The version increment from 3.2.0 to 3.2.1 is consistent with the PR's objectives.

packages/orm/src/client/crud/operations/update.ts (1)

46-47: LGTM! Refined read-back filter.

The read-back filter now uses only ID fields via getIdValues(), which prevents extraneous fields from the underlying executor result from polluting the filter. This is a more precise approach and aligns well with the intent to read back the specific entity by its identifier.

tests/regression/test/issue-584.test.ts (1)

1-140: LGTM! Comprehensive JSON default validation tests.

The tests thoroughly validate JSON default value handling for both scalar Json/Json? types (requiring JSON string literals) and Json[] array types (requiring arrays of JSON string literals). The test cases cover edge cases including null, plain strings, nested objects, and mixed value types.

tests/regression/test/issue-586.test.ts (1)

1-87: LGTM! Well-structured regression test.

The test verifies that JSON array updates with a custom mutation plugin don't trigger false "cannot-read-back" errors. The test setup is comprehensive with proper auth context, schema definition, and cleanup in the finally block. This test effectively validates the fix in the update operation handler.

packages/orm/src/client/crud-types.ts (1)

217-221: LGTM! Precise conditional typing for _count.

The conditional augmentation correctly adds the _count field to the result type only when it's explicitly included and not disabled. This type-level refinement improves IDE autocomplete and type safety by avoiding unnecessary _count fields in query results.

packages/sdk/src/ts-schema-generator.ts (2)

610-665: LGTM! Explicit null default handling is correctly implemented.

The null default value handling is well-integrated:

  • Line 610-613: Checks for null and emits ExpressionUtils._null()
  • Line 614: Properly excludes arrays from the object branch
  • Lines 773-774: getMappedValue correctly returns null for NullExpr
  • Type signatures (lines 731-739, 752) properly include | null

The logic correctly separates null, non-array objects, and arrays into distinct branches.


776-776: Improved error message provides better context.

Changing from "Unsupported default value type" to "Unsupported expression type" is more accurate since this function processes expressions, not just default values.

packages/language/src/validators/attribute-application-validator.ts (3)

396-411: Excellent refactor: Discriminated union enables precise error reporting.

The change from boolean return to { result: true } | { result: false; error: string } allows specific error messages to be propagated to users instead of generic "invalid argument type" messages. This significantly improves the developer experience.


619-629: JSON validation helper is concise and correct.

The isLiteralJsonString helper properly validates JSON by:

  1. Checking if the value is a string literal
  2. Attempting JSON.parse to validate JSON structure
  3. Catching parse errors and returning false

This is an appropriate validation strategy for JSON literals.


450-547: Consistent error propagation throughout the function.

All branches now return structured errors with specific messages:

  • Line 466: "expected array/non-array"
  • Line 482: "expected an array of field references"
  • Line 488: "expected a field reference"
  • Line 509: "expected array/non-array" (for enum mismatch)

The consistent use of the discriminated union pattern improves maintainability and error clarity.

tests/e2e/orm/client-api/find.test.ts (1)

1125-1169: Comprehensive test coverage for _count inside include.

The test validates three key scenarios:

  1. Lines 1130-1142: _count with select inside include
  2. Lines 1145-1155: _count with boolean true inside include
  3. Lines 1158-1168: _count with filtered posts inside include

Each scenario verifies:

  • Runtime behavior (correct counts)
  • TypeScript typing (comment line 1140 confirms type checking)
  • Both posts data and _count are accessible

The test aligns with the coding guideline to validate real-world schema compatibility.

Based on learnings, E2E tests should validate real-world schema compatibility with established projects.

tests/e2e/orm/schemas/typing/typecheck.ts (1)

165-182: TypeScript type validation for _count inside include is correctly implemented.

The type checks validate that:

  • Line 169: _count: { select: { posts: true } } is properly typed
  • Line 172-173: Both posts[0]?.title and _count.posts are accessible
  • Lines 175-182: Boolean _count: true syntax also works correctly

These compile-time checks complement the runtime tests in find.test.ts and ensure type inference is correct. The console.log statements serve as type assertions that will fail compilation if types are incorrect.

Based on learnings, TypeScript inference and type coverage should be validated through type coverage tests.

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

This PR merges the dev branch into main for the v3.2.1 release. The changes include bug fixes for JSON field validation and update operations, a new feature for _count support inside include queries, and version bumps across all packages.

Changes:

  • Version bumps from 3.2.0 to 3.2.1 across all packages
  • Fixed JSON field default value validation to require JSON string literals (issue #584)
  • Fixed read-back issue in update operations with mutation plugins (issue #586)
  • Added TypeScript support for _count inside include queries

Reviewed changes

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

Show a summary per file
File Description
packages/language/src/validators/attribute-application-validator.ts Enhanced validation for JSON default values with improved error messages
packages/sdk/src/ts-schema-generator.ts Added proper handling of null default values in schema generation
packages/orm/src/client/crud/operations/update.ts Fixed read-back logic to use only ID fields for querying after update
packages/orm/src/client/crud-types.ts Added TypeScript type support for _count property inside include
tests/regression/test/issue-584.test.ts Comprehensive tests for JSON default value validation
tests/regression/test/issue-586.test.ts Test for update read-back fix with mutation plugins
tests/e2e/orm/client-api/find.test.ts Tests for new _count inside include feature
tests/e2e/orm/schemas/typing/typecheck.ts Type-checking validation for _count in include
tests/e2e/orm/policy/crud/update.test.ts Import ordering cleanup
29 package.json files Consistent version bump to 3.2.1

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

@ymc9 ymc9 added this pull request to the merge queue Jan 11, 2026
Merged via the queue into main with commit d150edb Jan 11, 2026
16 checks passed
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.

3 participants