Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Dec 13, 2025

Summary by CodeRabbit

  • New Features

    • Added a database index on Asset.ownerId.
  • Bug Fixes

    • Excluded non-inheritable decorators from inherited attributes.
    • Adjusted Prisma schema attribute handling to include previously omitted attributes.
    • Narrowed delegate-model inheritance checks, refining relation validation behavior.
  • Chores

    • Bumped package versions to 3.0.0-beta.30 across the repo.
  • Tests

    • Updated a regression test to enable Prisma Push during test client creation.

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

github-actions bot and others added 2 commits December 13, 2025 21:39
* fix(delegate): exclude uninheritable attributes properly

* fix tests
Copilot AI review requested due to automatic review settings December 13, 2025 13:40
@coderabbitai
Copy link

coderabbitai bot commented Dec 13, 2025

Walkthrough

This PR updates many package versions from 3.0.0-beta.29 → 3.0.0-beta.30, adjusts attribute inheritance/filtering in the language and Prisma schema generator, narrows delegate-field inheritance checks, adds an index to an Asset test schema, and enables Prisma Push in a regression test.

Changes

Cohort / File(s) Change Summary
Version bumps (package.json files)
package.json, packages/auth-adapters/better-auth/package.json, packages/cli/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/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/next.js/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
Updated version from 3.0.0-beta.29 to 3.0.0-beta.30 across monorepo package.json files.
Attribute inheritance filtering (language utils)
packages/language/src/utils.ts
getAllAttributes now filters out non-inheritable model-level directives (@@map, @@unique, @@index) when appending inherited attributes; added isNonInheritableAttribute helper.
Prisma schema generation
packages/sdk/src/prisma/prisma-schema-generator.ts
Removed isInheritedMapAttribute helper and its exclusion; attribute collection now filters only by isPrismaAttribute, no longer excluding inherited @@map.
Delegate inheritance checks (validator)
packages/language/src/validators/datamodel-validator.ts
Tightened isFieldInheritedFromDelegateModel to accept contextModel and only treat fields inherited when the field's container is a different delegate model; updated call sites accordingly.
Tests — additions and config changes
packages/language/test/delegate.test.ts, tests/regression/test/v2-migrated/issue-1243.test.ts
Added a delegate relation test case verifying missing-opposite-relation rejection; changed two createTestClient(schema) calls to createTestClient(schema, { usePrismaPush: true }) in regression test.
Test schema index
tests/e2e/orm/schemas/delegate/schema.ts, tests/e2e/orm/schemas/delegate/schema.zmodel
Added @@index([ownerId]) to the Asset model (index on ownerId).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas needing extra attention:
    • Interaction between packages/language/src/utils.ts filtering and packages/sdk/src/prisma/prisma-schema-generator.ts removal of isInheritedMapAttribute — ensure intended inheritance semantics for model-level directives.
    • datamodel-validator.ts signature change and call-site updates — verify delegate inheritance behavior across cases and tests.
    • Regression test change enabling { usePrismaPush: true } may affect test environment expectations.

Possibly related PRs

Poem

🐰 Hopping through betas, from .29 to .30 I go,
I prune inherited bits that shouldn't show,
I tweak the validator, tidy Prisma's view,
An index on Asset, tests set to pursue.
🥕✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'merge dev to main (v3.0.0-beta.30)' accurately describes a release version bump across the entire codebase with version increments and bug fixes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

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 Dec 13, 2025

Claude finished @ymc9's task —— View job


PR Review Complete ✅

This PR merges dev → main for v3.0.0-beta.30, containing primarily version bumps and one important delegate inheritance fix.

Review Analysis:

  • Analyze version bump consistency across all packages
  • Review functional code changes in detail
  • Check test schema updates and coverage
  • Assess security and performance implications
  • Provide comprehensive feedback

Overall Assessment: APPROVED

Version Management

  • Consistent versioning: All packages properly bumped to 3.0.0-beta.30
  • VSCode extension: Correctly remains at 3.0.14 (marketplace doesn't support pre-release versions)
  • Clean version strategy: Follows semantic versioning properly

Key Bug Fix (Commit eb1a0c2)

Fix: Delegate inheritance properly excludes uninheritable attributes

Changes analyzed:

  1. packages/language/src/utils.ts:573-576: Added isNonInheritableAttribute() function that correctly identifies @@map, @@unique, and @@index as non-inheritable
  2. packages/sdk/src/prisma/prisma-schema-generator.ts:564: Simplified the code by moving logic to the language utils
  3. Test updates: Added proper test coverage for the fix

Code Quality:

  • ✅ Well-structured helper function
  • ✅ Clear separation of concerns
  • ✅ Proper array includes check for non-inheritable attributes
  • ✅ Good code organization by moving logic to appropriate utils module

Test Coverage

  • Regression test: issue-1243.test.ts properly validates the fix
  • E2E test: Delegate schema updated to include test for inheritance
  • Generated schema: Confirms fix works correctly in practice

Security & Performance

  • No security concerns: Changes are internal logic improvements
  • Performance: Minimal impact, just attribute filtering logic
  • No breaking changes: Backward compatible fix

Code Standards

  • Follows existing patterns and conventions
  • Proper TypeScript usage
  • Good function naming and organization
  • Maintains existing API contracts

Recommendations:

  • Ready to merge - This is a clean release preparation with important bug fix
  • Consider adding JSDoc to isNonInheritableAttribute() for future maintainability (minor)

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 to main for version 3.0.0-beta.30, bumping the version from beta.29 to beta.30 across all packages. The key change is a refactoring of how non-inheritable model-level attributes are handled in delegate inheritance. Previously, only the @@map attribute was filtered out during Prisma schema generation. Now, the filtering is done more comprehensively at the language utilities level, preventing @@map, @@unique, and @@index attributes from being inherited from base delegate models.

  • Refactored attribute inheritance logic to centralize filtering of non-inheritable attributes (@@map, @@unique, @@index) in the language utilities layer
  • Added test coverage for delegate inheritance with multiple non-inheritable attributes
  • Updated delegate schema examples to demonstrate proper behavior with non-inherited @@index attributes

Reviewed changes

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

Show a summary per file
File Description
package.json Version bump to 3.0.0-beta.30
packages/auth-adapters/better-auth/package.json Version bump to 3.0.0-beta.30
packages/cli/package.json Version bump to 3.0.0-beta.30
packages/clients/tanstack-query/package.json Version bump to 3.0.0-beta.30
packages/common-helpers/package.json Version bump to 3.0.0-beta.30
packages/config/eslint-config/package.json Version bump to 3.0.0-beta.30
packages/config/typescript-config/package.json Version bump to 3.0.0-beta.30
packages/config/vitest-config/package.json Version bump to 3.0.0-beta.30
packages/create-zenstack/package.json Version bump to 3.0.0-beta.30
packages/language/package.json Version bump to 3.0.0-beta.30
packages/language/src/utils.ts Added isNonInheritableAttribute function to filter @@Map, @@unique, and @@index from inherited attributes
packages/orm/package.json Version bump to 3.0.0-beta.30
packages/plugins/policy/package.json Version bump to 3.0.0-beta.30
packages/schema/package.json Version bump to 3.0.0-beta.30
packages/sdk/package.json Version bump to 3.0.0-beta.30
packages/sdk/src/prisma/prisma-schema-generator.ts Removed isInheritedMapAttribute method; filtering now handled centrally in utils.ts
packages/server/package.json Version bump to 3.0.0-beta.30
packages/testtools/package.json Version bump to 3.0.0-beta.30
packages/zod/package.json Version bump to 3.0.0-beta.30
samples/next.js/package.json Version bump to 3.0.0-beta.30
samples/orm/package.json Version bump to 3.0.0-beta.30
tests/e2e/package.json Version bump to 3.0.0-beta.30
tests/e2e/orm/schemas/delegate/schema.zmodel Added @@index([ownerId]) to Asset model to demonstrate non-inheritance
tests/e2e/orm/schemas/delegate/schema.ts Generated schema updated with @@index attribute on Asset (not inherited by Video/Image)
tests/regression/package.json Version bump to 3.0.0-beta.30
tests/regression/test/v2-migrated/issue-1243.test.ts Added usePrismaPush option to properly test delegate inheritance with non-inheritable attributes
tests/runtimes/bun/package.json Version bump to 3.0.0-beta.30
tests/runtimes/edge-runtime/package.json Version bump to 3.0.0-beta.30

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

@claude
Copy link

claude bot commented Dec 14, 2025

Claude finished @ymc9's task —— View job


PR Review - v3.0.0-beta.30 Release

Reviewing this PR for code quality, potential bugs, performance, security, and test coverage.

Review Tasks:

  • Analyze version bump consistency across all packages
  • Review functional code changes in detail
  • Check test schema updates and coverage
  • Assess security and performance implications
  • Provide comprehensive feedback

Overall Assessment: APPROVED

Version Management

  • Consistent versioning: All packages properly bumped to 3.0.0-beta.30
  • VSCode extension: Correctly remains at 3.0.14 (marketplace doesn't support pre-release versions)
  • Clean version strategy: Follows semantic versioning properly

Key Bug Fix (Commit eb1a0c2)

Fix: Delegate inheritance properly excludes uninheritable attributes

Changes analyzed:

  1. packages/language/src/utils.ts:573-576: Added isNonInheritableAttribute() function that correctly identifies @@map, @@unique, and @@index as non-inheritable
  2. packages/sdk/src/prisma/prisma-schema-generator.ts:564: Simplified the code by moving logic to the language utils
  3. Test updates: Added proper test coverage for the fix

Code Quality:

  • ✅ Well-structured helper function
  • ✅ Clear separation of concerns
  • ✅ Proper array includes check for non-inheritable attributes
  • ✅ Good code organization by moving logic to appropriate utils module

Test Coverage

  • Regression test: issue-1243.test.ts properly validates the fix
  • E2E test: Delegate schema updated to include test for inheritance
  • Generated schema: Confirms fix works correctly in practice

Security & Performance

  • No security concerns: Changes are internal logic improvements
  • Performance: Minimal impact, just attribute filtering logic
  • No breaking changes: Backward compatible fix

Code Standards

  • Follows existing patterns and conventions
  • Proper TypeScript usage
  • Good function naming and organization
  • Maintains existing API contracts

Recommendations:

  • Ready to merge - This is a clean release preparation with important bug fix
  • Consider adding JSDoc to isNonInheritableAttribute() for future maintainability (minor)

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: 0

🧹 Nitpick comments (1)
packages/language/src/validators/datamodel-validator.ts (1)

433-436: Doc/semantics mismatch: “directly or indirectly” vs actual check.
The helper currently checks only whether the field’s declaring container is a delegate model and differs from contextModel. If “indirectly” is intended (multi-level inheritance), that’s probably still fine as long as the declaring container is always the original delegate ancestor—but the comment should reflect the actual criterion (declared-on-delegate-and-not-context), not imply traversal.

📜 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 eb1a0c2 and 081e434.

📒 Files selected for processing (2)
  • packages/language/src/validators/datamodel-validator.ts (2 hunks)
  • packages/language/test/delegate.test.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 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:

  • packages/language/test/delegate.test.ts
⏰ 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). (3)
  • GitHub Check: build-test (20.x, postgresql)
  • GitHub Check: build-test (20.x, sqlite)
  • GitHub Check: claude-review
🔇 Additional comments (2)
packages/language/test/delegate.test.ts (1)

118-166: Nice regression coverage for delegate relation opposites.
The two-step schema (error then no-error) matches the validator behavior change and should prevent this from regressing.

packages/language/src/validators/datamodel-validator.ts (1)

247-256: Good: opposite-relation check is now context-aware (but relies on $container semantics).
Passing contextModel into isFieldInheritedFromDelegateModel seems to match the intended behavior change (delegate model’s own relation fields now require opposites; inherited ones don’t). Please double-check that getAllFields(dm) returns inherited DataFields with $container still pointing at the base model (not the derived model), otherwise this condition can silently misclassify fields.

#!/bin/bash
# Verify how getAllFields constructs/returns inherited fields and whether it preserves DataField.$container.

rg -n --type=ts "function getAllFields\\b|const getAllFields\\b|export function getAllFields\\b" -S
rg -n --type=ts "getAllFields\\(" packages/language/src -S

@ymc9 ymc9 added this pull request to the merge queue Dec 14, 2025
Merged via the queue into main with commit 39fb7d3 Dec 14, 2025
9 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.

2 participants