Skip to content

merge dev to main (v3.6.2)#2608

Merged
ymc9 merged 6 commits intomainfrom
dev
Apr 23, 2026
Merged

merge dev to main (v3.6.2)#2608
ymc9 merged 6 commits intomainfrom
dev

Conversation

@ymc9
Copy link
Copy Markdown
Member

@ymc9 ymc9 commented Apr 22, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed PostgreSQL schema handling for implicit many-to-many relations to use correct schema instead of defaulting to public.
    • Fixed policy enforcement for post-update operations with nested conditions and delegate models.
  • Chores

    • Released version 3.6.2.
    • Added optional h3 peer dependency support.
    • Added regression tests for policy and schema edge cases.

genu and others added 6 commits April 22, 2026 10:08
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
…DeleGate sub-models (#2605)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…reSQL schemas (#2606)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a regression test for nested collection predicates in access
policies generating valid SQL (issue #2538).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

📝 Walkthrough

Walkthrough

This pull request performs a monorepo-wide version bump from 3.6.1 to 3.6.2, adds PostgreSQL schema support for implicit many-to-many join tables, updates policy handler logic for delegate sub-models, declares h3 as an optional peer dependency, and introduces three regression test cases.

Changes

Cohort / File(s) Summary
Version Bumps
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/tsdown-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/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
Updates all package versions from 3.6.1 to 3.6.2 across monorepo.
Server Peer Dependency
packages/server/package.json
Adds h3 (^1.15.0) as an optional peer dependency alongside version bump to 3.6.2.
PostgreSQL Many-to-Many Schema Support
packages/orm/src/client/executor/name-mapper.ts
Introduces joinTableSchemaMap to precompute schemas for implicit many-to-many join tables by scanning model relations and using the alphabetically-first model's schema, with fallback to 'public'.
Policy Handler Delegate Sub-Models
packages/plugins/policy/src/policy-handler.ts
Updates loadBeforeUpdateEntities pre-update readback query to qualify selected columns with table names, detect base-model fields, and conditionally add LEFT JOINs to base tables.
Regression Tests
tests/regression/test/issue-2538.test.ts, tests/regression/test/issue-2595.test.ts, tests/regression/test/issue-2603.test.ts
Adds three regression test suites: nested collection predicates in policies (2538), post-update denial rules with status transitions (2595), and PostgreSQL schema handling for many-to-many joins (2603).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🐰 Version bumps abound, from three to two,
Many-to-many joins now find their schema true,
Policies dance with delegates bold,
Tests catch the edge cases, new stories to tell!
Hop along, version three-point-six-two's here!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'merge dev to main (v3.6.2)' accurately reflects the primary purpose and matches the changeset, which is a version bump from 3.6.1 to 3.6.2 across all packages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 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
Copy Markdown
Contributor

claude Bot commented Apr 22, 2026

Claude finished @ymc9's task —— View job


Code Review for v3.6.2 Release PR ✅

Comprehensive review completed for this merge from dev to main for v3.6.2 release.

Review Tasks

  • Analyze functional code changes
  • Review new regression tests
  • Check for code quality and best practices
  • Identify potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Review test coverage

APPROVE - This PR is ready for merge

Key Functional Changes

1. PostgreSQL Schema Support Enhancement (packages/orm/src/client/executor/name-mapper.ts:87-102)

2. Delegate Sub-model Policy Enhancement (packages/plugins/policy/src/policy-handler.ts:590-618)

Regression Test Coverage ✅

3 comprehensive regression tests added:

Code Quality Assessment ✅

Strengths:

  • Clean Architecture: Changes follow existing patterns and maintain separation of concerns
  • Robust Error Handling: Proper use of invariant() assertions and graceful fallbacks
  • Type Safety: Full TypeScript typing maintained throughout
  • Documentation: Good inline comments explaining complex logic

Performance Considerations ✅

  • Schema mapping is computed once in constructor and cached
  • Join operations only performed when needed for inherited fields
  • No unnecessary query overhead introduced

Security Review ✅

  • No introduction of security vulnerabilities
  • Proper validation and assertion checks maintained
  • No exposure of internal data structures

Version Management ✅

  • Consistent versioning: All 28 packages properly bumped to v3.6.2
  • Dependency alignment: Workspace dependencies correctly maintained
  • Package integrity: No dependency version conflicts detected

Test Coverage ✅

  • Comprehensive regression tests: All fixed issues have corresponding test coverage
  • Real-world scenarios: Tests cover complex nested relationships and schema configurations
  • Edge cases covered: Multiple PostgreSQL schema configurations tested

Recommendations

  1. Ship it! - This is a solid release with important bug fixes
  2. All changes are backward compatible
  3. Test coverage is excellent
  4. Code quality meets project standards

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/orm/src/client/executor/name-mapper.ts (1)

567-585: ⚠️ Potential issue | 🟡 Minor

Subtle behavior change: unknown tables now force 'public' instead of defaultSchema.

Previously, getTableSchema(model) would fall through to defaultSchema ?? 'public' for any name, including tables not in $schema.models. Now, any name not in $schema.models returns joinTableSchemaMap.get(model) ?? 'public', ignoring defaultSchema.

For implicit m2m join tables this is correct (they're precomputed). But for any other non-model table name that might flow through processTableRef (e.g., raw-query table refs, future extensions, or any model name that doesn't exist as a key for some reason), the schema will now incorrectly default to 'public' instead of the user-configured defaultSchema. Consider falling back to defaultSchema when the name is not in joinTableSchemaMap:

Suggested fallback
         if (!this.schema.models[model]) {
-            return this.joinTableSchemaMap.get(model) ?? 'public';
+            return this.joinTableSchemaMap.get(model) ?? this.schema.provider.defaultSchema ?? 'public';
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/orm/src/client/executor/name-mapper.ts` around lines 567 - 585, The
getTableSchema function currently returns joinTableSchemaMap.get(model) ??
'public' when model is not found in this.schema.models, which ignores the
configured defaultSchema; update getTableSchema (in name-mapper.ts) so that for
non-model names you first check joinTableSchemaMap.get(model) and if that is
undefined you fall back to this.schema.provider.defaultSchema ?? 'public'
instead of always 'public'. Keep the existing logic for models (respecting
@@schema map args) and only change the fallback path for the
not-in-this.schema.models branch to use defaultSchema.
🧹 Nitpick comments (1)
tests/regression/test/issue-2603.test.ts (1)

8-8: Nit: describe title missing # for consistency.

The sibling regression tests use Regression for issue #2538`` / #2595; consider aligning to `'Regression for issue `#2603`'`.

Proposed tweak
-describe('Regression for issue 2603', () => {
+describe('Regression for issue `#2603`', () => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/regression/test/issue-2603.test.ts` at line 8, Update the test suite
title string in the describe call so it matches the sibling tests' format by
adding a '#' before the issue number; change the describe labeled "Regression
for issue 2603" to "Regression for issue `#2603`" (locate the describe invocation
in tests/regression/test/issue-2603.test.ts).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/orm/src/client/executor/name-mapper.ts`:
- Around line 567-585: The getTableSchema function currently returns
joinTableSchemaMap.get(model) ?? 'public' when model is not found in
this.schema.models, which ignores the configured defaultSchema; update
getTableSchema (in name-mapper.ts) so that for non-model names you first check
joinTableSchemaMap.get(model) and if that is undefined you fall back to
this.schema.provider.defaultSchema ?? 'public' instead of always 'public'. Keep
the existing logic for models (respecting @@schema map args) and only change the
fallback path for the not-in-this.schema.models branch to use defaultSchema.

---

Nitpick comments:
In `@tests/regression/test/issue-2603.test.ts`:
- Line 8: Update the test suite title string in the describe call so it matches
the sibling tests' format by adding a '#' before the issue number; change the
describe labeled "Regression for issue 2603" to "Regression for issue `#2603`"
(locate the describe invocation in tests/regression/test/issue-2603.test.ts).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8b88e82a-a0df-490c-9752-bc356aec7517

📥 Commits

Reviewing files that changed from the base of the PR and between a21a56f and 09ca875.

📒 Files selected for processing (30)
  • 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/tsdown-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/orm/src/client/executor/name-mapper.ts
  • packages/plugins/policy/package.json
  • packages/plugins/policy/src/policy-handler.ts
  • 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/regression/test/issue-2538.test.ts
  • tests/regression/test/issue-2595.test.ts
  • tests/regression/test/issue-2603.test.ts
  • tests/runtimes/bun/package.json
  • tests/runtimes/edge-runtime/package.json

@ymc9 ymc9 merged commit 26972be into main Apr 23, 2026
14 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