Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Nov 14, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced test client with support for SQLite and PostgreSQL provider selection, file copying, data source extensions, and debug mode.
    • Default Prisma client generator now automatically created when not explicitly defined in schemas.
  • Bug Fixes

    • Improved join condition processing to properly propagate database scopes, enabling join clauses to correctly reference from-table columns.
  • Tests

    • Added comprehensive end-to-end test suite demonstrating complex multi-model queries and data relationships.

Copilot AI review requested due to automatic review settings November 14, 2025 21:00
@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

Walkthrough

This PR extends join processing in the query name mapper with scope awareness for improved from-clause table references, adds automatic default Prisma client generator configuration with extension support, significantly expands test client options to support file operations and datasource extensions, introduces a comprehensive Rally polling application end-to-end test suite with full ZenStack model definitions covering users, spaces, polls, events, billing, and licensing, and updates code generation scripts to scan application-level schemas alongside existing test schemas.

Changes

Cohort / File(s) Summary
Core ORM Name Mapper
packages/orm/src/client/executor/name-mapper.ts
Modified join processing in transformSelectQuery to collect scopes from processedFroms and apply them during join table processing via withScopes, enabling join conditions to reference from-clause tables while preserving merged from-scope and join-scope union.
Prisma Schema Generation
packages/sdk/src/prisma/prisma-schema-generator.ts
Added isGeneratorDecl import and logic to invoke generateDefaultGenerator if no GeneratorDecl exists; new method generates default client generator with "prisma-client-js" provider and adds "postgresqlExtensions" preview feature when datasource has extensions field.
Test Client Infrastructure
packages/testtools/src/client.ts
Expanded CreateTestClientOptions<Schema> type with 10 new fields (provider, schemaFile, dbName, usePrismaPush, extraSourceFiles, workDir, debug, dbFile, dataSourceExtensions, copyFiles); implemented glob-based file copying, dbFile validation for sqlite-only, and datasource extensions configuration.
Rally E2E App Schema
tests/e2e/apps/rally/zenstack/schema.zmodel
Added imports for user, space, poll, instance-settings, licensing, integrations, event, and billing models; defined PostgreSQL datasource configuration.
Rally E2E App Models
tests/e2e/apps/rally/zenstack/models/{user,space,poll,billing,event,instance-settings,licensing,integrations}.zmodel
Introduced comprehensive domain models covering user authentication, space management, polling functionality, event scheduling with invites, billing subscriptions, OAuth credentials, calendar integrations, licensing tiers, and instance settings; includes enums (TimeFormat, UserRole, SpaceMemberRole, etc.), relational definitions with cascade/set-null behaviors, and DB mappings.
Rally E2E Generated Types
tests/e2e/apps/rally/zenstack/{input,models}.ts
Auto-generated TypeScript type definitions providing Find/Create/Update/Delete/Count/Aggregate/GroupBy argument and payload types for all models; exported model result types and enum accessor types mirrored from schema.
Rally E2E Test Suite
tests/e2e/apps/rally/rally.test.ts
New test file using createTestClient to initialize PostgreSQL database with schema, citext extension, Prisma push, and debug mode; queries spaceMember with userId filtering and related space field selection.
Name Mapping Test Extensions
tests/e2e/orm/client-api/name-mapping.test.ts
Added nested include test for User.findFirst filtering posts by title; added alternative join test using innerJoin with join.onRef callback and whereRef condition.
Name Mapping Schema Updates
tests/e2e/orm/schemas/name-mapping/schema.{ts,zmodel}
Added @map attributes on id fields: User.id → "user_id" and Post.id → "post_id" in both TypeScript and ZenStack schema definitions.
Test Script Updates
tests/e2e/scripts/generate.ts, tests/e2e/package.json
Modified generate script to scan both orm/schemas/**/*.zmodel and apps/**/schema.zmodel for code generation; updated "test:generate" npm script path from orm/scripts/generate.ts to scripts/generate.ts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

  • Name mapper logic: Verify scope collection and propagation correctness; ensure from-scope and join-scope union is properly maintained
  • Test client API surface: Review all 10 new options for correctness, edge cases (dbFile sqlite-only validation, glob pattern matching, destination directory creation); verify datasource extension injection logic
  • Rally schema models: Validate relational integrity, cascade/set-null configurations, unique constraints, and field mapping correctness across all 8 model files; cross-check enum definitions match usage
  • Generated type definitions: Verify the generated input.ts and models.ts exports align with schema; spot-check a few type aliases for correct generic parameterization

Possibly related PRs

Poem

🐰 Hops with glee through Rally's halls so grand,
Scopes now dance with joins across the land,
Generators birth clients without a fret,
While test tools copy files—no hassle yet!
Extensions bloom like flowers in the spring! 🌸

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 accurately summarizes the main fix: foreign key name mapping in joins. This is the primary change in the name-mapper.ts file and reflected throughout the PR changes.
✨ 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 fix/join-name-mapping

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 Nov 14, 2025

Claude finished @ymc9's task —— View job


Code Review Complete

Reviewing PR #400: Foreign Key Name Mapping Fix

Review Tasks:

  • Read repository guidelines and context
  • Analyze core logic changes in name-mapper.ts
  • Review Prisma schema generator changes
  • Examine test coverage and new test cases
  • Assess code quality and potential issues
  • Check for security and performance concerns
  • Provide comprehensive feedback

Summary

This PR fixes a critical bug in the ORM's name mapping functionality where foreign key references in JOIN conditions weren't being properly resolved due to missing scope context.

Code Quality & Architecture

✅ Core Fix (name-mapper.ts:80-84)

The fix addresses a scoping issue in transformSelectQuery():

// OLD: Join processing without FROM table scopes
const processedJoins = (node.joins ?? []).map((join) => this.processSelectTable(join.table));

// NEW: Join processing with FROM table scopes available
const processedJoins = this.withScopes([...processedFroms.map(({ scope }) => scope)], () =>
    (node.joins ?? []).map((join) => this.processSelectTable(join.table)),
);

Impact: When processing JOIN conditions, the resolveFieldFromScopes() method can now properly resolve field references to tables in the FROM clause, enabling correct name mapping for foreign key columns.

✅ Schema Generator Enhancement (prisma-schema-generator.ts:109-113)

Automatically adds default Prisma client generator when missing:

if (!this.zmodel.declarations.some(isGeneratorDecl)) {
    this.generateDefaultGenerator(prisma);
}

Benefits:

  • Reduces boilerplate in test schemas
  • Handles PostgreSQL extensions automatically
  • Follows principle of convention over configuration

✅ Test Infrastructure Improvements (testtools/client.ts)

Significant enhancements to test setup capabilities:

  • File copying: Supports glob patterns for additional test files
  • DataSource extensions: PostgreSQL extension support
  • Better debugging: Enhanced logging and work directory visibility
  • Flexible schema handling: Supports both inline and file-based schemas

Test Coverage

✅ Comprehensive Testing

  1. Specific regression test: Added JOIN test case that would have failed before the fix
  2. Real-world validation: Rally app test suite with 204 @map directives across 8 model files
  3. Edge case coverage: Nested selects, complex relations, and enum mappings

✅ Test Quality

  • Uses realistic schema structure from actual application (Rally)
  • Tests both high-level ORM API and low-level Kysely query builder
  • Validates correct foreign key resolution in various scenarios

Potential Issues

⚠️ Minor: Error Handling

The fix assumes processedFroms.map(({ scope }) => scope) will always succeed. Consider adding null checks:

const processedJoins = this.withScopes(
    processedFroms.map(({ scope }) => scope).filter(Boolean), 
    () => (node.joins ?? []).map((join) => this.processSelectTable(join.table))
);

✅ Performance Considerations

  • Scope management is lightweight (array push/pop operations)
  • No additional database queries introduced
  • Minimal memory overhead from scope stack

Security Assessment

✅ No Security Concerns

  • Changes are purely internal to query transformation logic
  • No user input handling modifications
  • No credential or sensitive data exposure

Recommendations

  1. ✅ Approve: This is a well-implemented fix for a legitimate bug
  2. Consider: Adding JSDoc comments to explain the scoping logic in transformSelectQuery()
  3. Future: Consider extracting scope management into a separate utility class for better testability

Conclusion

This PR demonstrates excellent debugging and problem-solving. The fix is surgical, well-tested, and addresses the root cause without introducing side effects. The additional test infrastructure improvements are valuable for the project's long-term maintainability.

Verdict: LGTM

Copilot finished reviewing on behalf of ymc9 November 14, 2025 21:02
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 fixes a bug where foreign key name mapping was not properly handled in JOIN clauses. The issue was that when processing JOIN conditions, the scope from FROM clauses wasn't available, causing field name resolution to fail when field names were mapped using @map.

Key Changes

  • Updated QueryNameMapper.transformSelectQuery to make FROM table scopes available when processing JOIN clauses
  • Added @map attributes to primary key fields in the name-mapping test schema to test the fix
  • Added test cases to verify JOIN queries work correctly with mapped field names
  • Enhanced test infrastructure with new Rally app test setup and improved test client options

Reviewed Changes

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

Show a summary per file
File Description
packages/orm/src/client/executor/name-mapper.ts Core fix: Added FROM scopes when processing JOINs
tests/e2e/orm/client-api/name-mapping.test.ts Added test cases for nested selects and joins with mapped IDs
tests/e2e/orm/schemas/name-mapping/schema.zmodel Added @Map to id fields to test the fix
packages/testtools/src/client.ts Enhanced with copyFiles, dataSourceExtensions, and better documentation
packages/sdk/src/prisma/prisma-schema-generator.ts Auto-generate default generator with postgresqlExtensions preview feature
tests/e2e/apps/rally/* New Rally app test infrastructure with complex schema

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

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 (5)
packages/testtools/src/client.ts (1)

168-184: Verify expect.getState() availability in all test contexts.

The copyFiles implementation relies on expect.getState() to determine the current test file path. While this works with Vitest's expect API, verify that testPath is reliably available in all test execution modes (e.g., parallel execution, different test runners).

Consider adding more context to the error message if testPath is unavailable:

 if (!currentTestPath) {
-    throw new Error('Unable to determine current test file path');
+    throw new Error('Unable to determine current test file path. The copyFiles option requires running within a Vitest test context.');
 }
tests/e2e/apps/rally/rally.test.ts (2)

10-24: Consider adding teardown to disconnect the test client

beforeEach creates a new ClientContract with a Postgres dialect, but there's no corresponding afterEach/afterAll calling db.$disconnect(). Over time (or when you add more tests), this can leave open DB connections and keep Node’s event loop alive longer than necessary.

I recommend mirroring the pattern used in other e2e tests and adding a teardown:

import { afterEach } from 'vitest';

afterEach(async () => {
    await db.$disconnect();
});

26-48: Verify toResolveTruthy matcher or prefer standard .resolves.toBeTruthy()

await expect(db.spaceMember.findMany({...})).toResolveTruthy(); is a bit unconventional for Vitest’s core API, which typically uses await expect(promise).resolves.toBeTruthy() (or similar). If you’ve registered a custom matcher providing toResolveTruthy, that’s fine—otherwise this will throw at runtime.

If there’s no explicit custom matcher, I’d switch to:

await expect(
    db.spaceMember.findMany({
        // ...
    }),
).resolves.toBeTruthy();

Functionally it still asserts that the query resolves without error and returns a truthy value.

tests/e2e/apps/rally/zenstack/models/integrations.zmodel (2)

24-25: Consider avoiding duplicate constraint name across tables

Both Credential (Line 24) and CalendarConnection (Line 48) use @@unique([userId, provider, providerAccountId], name: "user_provider_account_unique"). Reusing the same constraint name across different tables can cause conflicts on databases where constraint names must be schema‑unique. Unless you’re intentionally mirroring an existing schema that already does this, consider either dropping the explicit name: (and letting the tooling generate one) or giving each table its own unique constraint name.

Also applies to: 48-49


72-75: Clarify semantics of lastSyncedAt default

lastSyncedAt is non‑nullable with @default(now()). That makes a newly created ProviderCalendar look as if it has already been synced once. If “never synced” is a meaningful state, you might prefer DateTime? without a default and treat null as “not yet synced”.

📜 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 982a36c and 6166b28.

📒 Files selected for processing (20)
  • packages/orm/src/client/executor/name-mapper.ts (1 hunks)
  • packages/sdk/src/prisma/prisma-schema-generator.ts (3 hunks)
  • packages/testtools/src/client.ts (4 hunks)
  • tests/e2e/apps/rally/rally.test.ts (1 hunks)
  • tests/e2e/apps/rally/zenstack/input.ts (1 hunks)
  • tests/e2e/apps/rally/zenstack/models.ts (1 hunks)
  • tests/e2e/apps/rally/zenstack/models/billing.zmodel (1 hunks)
  • tests/e2e/apps/rally/zenstack/models/event.zmodel (1 hunks)
  • tests/e2e/apps/rally/zenstack/models/instance-settings.zmodel (1 hunks)
  • tests/e2e/apps/rally/zenstack/models/integrations.zmodel (1 hunks)
  • tests/e2e/apps/rally/zenstack/models/licensing.zmodel (1 hunks)
  • tests/e2e/apps/rally/zenstack/models/poll.zmodel (1 hunks)
  • tests/e2e/apps/rally/zenstack/models/space.zmodel (1 hunks)
  • tests/e2e/apps/rally/zenstack/models/user.zmodel (1 hunks)
  • tests/e2e/apps/rally/zenstack/schema.zmodel (1 hunks)
  • tests/e2e/orm/client-api/name-mapping.test.ts (2 hunks)
  • tests/e2e/orm/schemas/name-mapping/schema.ts (2 hunks)
  • tests/e2e/orm/schemas/name-mapping/schema.zmodel (1 hunks)
  • tests/e2e/package.json (1 hunks)
  • tests/e2e/scripts/generate.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-21T16:09:31.218Z
Learnt from: ymc9
Repo: zenstackhq/zenstack-v3 PR: 319
File: packages/runtime/src/client/executor/zenstack-query-executor.ts:63-72
Timestamp: 2025-10-21T16:09:31.218Z
Learning: In ZenStack, TypeDefs can be inherited by models. When a TypeDef contains fields with `map` attributes, those mapped field names need to be processed by the QueryNameMapper since they become part of the inheriting model's schema. Therefore, when checking if a schema has mapped names (e.g., in `schemaHasMappedNames`), both `schema.models` and `schema.typeDefs` must be inspected for `@map` and `map` attributes.

Applied to files:

  • tests/e2e/apps/rally/zenstack/schema.zmodel
  • tests/e2e/orm/schemas/name-mapping/schema.zmodel
  • tests/e2e/apps/rally/zenstack/models/user.zmodel
  • tests/e2e/orm/schemas/name-mapping/schema.ts
  • tests/e2e/apps/rally/zenstack/models/licensing.zmodel
  • tests/e2e/apps/rally/zenstack/models.ts
🧬 Code graph analysis (4)
tests/e2e/apps/rally/rally.test.ts (3)
packages/orm/src/client/contract.ts (1)
  • ClientContract (52-172)
tests/e2e/apps/rally/zenstack/schema.ts (2)
  • SchemaType (2523-2523)
  • schema (9-2522)
packages/testtools/src/client.ts (1)
  • createTestClient (95-244)
tests/e2e/orm/schemas/name-mapping/schema.ts (1)
packages/schema/src/expression-utils.ts (1)
  • ExpressionUtils (19-123)
packages/testtools/src/client.ts (2)
packages/common-helpers/src/tiny-invariant.ts (1)
  • invariant (4-14)
packages/orm/src/client/options.ts (1)
  • ClientOptions (45-96)
packages/sdk/src/prisma/prisma-schema-generator.ts (2)
packages/language/src/generated/ast.ts (2)
  • isGeneratorDecl (516-518)
  • isDataSource (417-419)
packages/sdk/src/prisma/prisma-builder.ts (1)
  • PrismaModel (11-52)
⏰ 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). (4)
  • GitHub Check: Agent
  • GitHub Check: claude-review
  • GitHub Check: build-test (20.x, postgresql)
  • GitHub Check: build-test (20.x, sqlite)
🔇 Additional comments (24)
tests/e2e/scripts/generate.ts (2)

11-14: LGTM! Expanded schema scanning aligns with test suite enhancements.

The addition of apps/**/schema.zmodel to the generation sources enables scanning application-level schemas alongside existing ORM test schemas, which supports the new Rally e2e test suite introduced in this PR.


29-29: Plugin path change is correct; runtime verification needed.

The review comment's technical assessment is accurate: the file was moved from tests/e2e/orm/scripts/generate.ts to tests/e2e/scripts/generate.ts, and the plugin path correctly changed from ../../node_modules (two levels up) to ../node_modules (one level up). Both resolve to tests/e2e/node_modules/@zenstackhq/plugin-policy/plugin.zmodel.

Since @zenstackhq/plugin-policy is listed in tests/e2e/package.json as a workspace dependency ("workspace:*"), pnpm should resolve it to node_modules at install time. However, the node_modules structure is not available in this environment, so runtime verification is needed to confirm the path resolves correctly when the script executes.

tests/e2e/package.json (1)

8-8: LGTM! Script path update aligns with file relocation.

The test:generate script now points to the correct location after the generate.ts file was moved from orm/scripts/ to scripts/.

packages/orm/src/client/executor/name-mapper.ts (1)

80-84: Excellent fix for scope-aware join processing!

This change correctly makes from-clause scopes available when processing join tables. Previously, join conditions couldn't properly resolve references to tables defined in the FROM clause, causing name mapping issues for foreign keys in joins. By wrapping join processing in withScopes([...processedFroms.map(({ scope }) => scope)]), join conditions can now correctly reference and map names for from-clause tables.

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

110-112: Verify behavioral implications of auto-generating default generator.

Automatically adding a default Prisma client generator when none is declared changes the behavior for schemas without explicit generators. While this is likely the desired behavior for most use cases, confirm that this won't break existing workflows that intentionally omit generator declarations.


177-184: PostgreSQL extensions preview feature name is correct.

The preview feature name "postgresqlExtensions" is confirmed as correct per Prisma's official documentation. The code at lines 177-184 properly implements this feature name and requires no changes.

tests/e2e/orm/schemas/name-mapping/schema.zmodel (1)

14-14: LGTM! Test data enhancements for join name mapping.

Adding @map attributes to ID fields creates the test scenario needed to verify that foreign key references in join conditions correctly resolve mapped identifier names. This directly tests the scope-aware join processing fix.

Also applies to: 22-22

tests/e2e/apps/rally/zenstack/models/event.zmodel (2)

22-49: LGTM! Well-structured event model with comprehensive relationships.

The ScheduledEvent model includes proper foreign key constraints, cascading deletes, appropriate indexes (Hash type for PostgreSQL optimization), and comprehensive field mappings. The relations to User, Space, and related entities are correctly defined.


65-83: LGTM! ScheduledEventInvite model follows best practices.

The model correctly implements:

  • Optional relation to User with SetNull on delete (line 77), which is appropriate for invite tracking even after user deletion
  • Proper cascading delete for the scheduledEvent relation (line 76)
  • Well-indexed foreign keys for query performance (lines 79-81)
packages/testtools/src/client.ts (2)

35-85: LGTM! Comprehensive expansion of test client options.

The expanded options interface provides valuable capabilities:

  • dbFile: Enables reusing existing SQLite databases
  • dataSourceExtensions: Supports PostgreSQL extensions in tests
  • copyFiles: Allows copying additional test fixtures

The option definitions are well-documented and type-safe.


140-140: LGTM! Extension support integrates with generator changes.

The conditional insertion of extensions = [...] into the datasource block correctly integrates with the default generator's postgresqlExtensions preview feature added in packages/sdk/src/prisma/prisma-schema-generator.ts.

tests/e2e/apps/rally/zenstack/schema.zmodel (1)

1-12: LGTM! Schema integrates Rally e2e test models.

This schema file serves as the entry point for the comprehensive Rally application test suite, importing all necessary model definitions. The datasource is intentionally minimal since the URL is injected by the test tooling (as seen in packages/testtools/src/client.ts).

tests/e2e/orm/client-api/name-mapping.test.ts (2)

160-167: Nested include test correctly exercises FK mapping

This include: { posts: { where: { title: 'Post1' } } } plus the authorId: user.id assertion is a good, focused regression test for relation/foreign-key name mapping on nested includes. No issues from my side; this should catch regressions in how mapped FK names are resolved inside include filters and payloads.


211-221: Alternative join variant provides solid coverage for join callback path

This innerJoin('User', (join) => join.onRef('User.id', '=', 'Post.authorId')) mirrors the previous positional join test and properly asserts authorId and title. It exercises the join-callback path of the name mapper, which is exactly where the bug was. Looks good.

tests/e2e/orm/schemas/name-mapping/schema.ts (1)

17-23: ID field @map attributes align with underlying column names

Adding @map("user_id") to User.id and @map("post_id") to Post.id in the generated schema is consistent with your table naming (users.user_id, posts.post_id) and ensures the name-mapper sees the correct PK column names for joins. Looks coherent with the rest of the mapped fields (email, role, authorId).

Also applies to: 55-61

tests/e2e/apps/rally/zenstack/models/instance-settings.zmodel (1)

1-10: InstanceSettings model looks consistent for a singleton settings table

The InstanceSettings definition (fixed PK id @default(1), mapped snake_case columns, @updatedAt on updatedAt) is coherent and matches the shape of a one-row instance-level settings table. No issues spotted.

tests/e2e/apps/rally/zenstack/models/space.zmodel (1)

1-73: Space and membership models/enums are well-structured and align with Rally tests

The Space, SpaceMember, and SpaceMemberInvite models plus SpaceMemberRole/SpaceTier enums are wired cleanly:

  • FK fields (ownerId, spaceId, userId, inviterId) and timestamps are correctly mapped to snake_case columns.
  • Relations specify onDelete: Cascade and unique/index constraints that match expected access patterns.
  • SpaceMember exposes userId, lastSelectedAt, and space exactly as used in rally.test.ts.

This schema should work well with the Postgres-backed Rally e2e tests and the name-mapping logic.

tests/e2e/apps/rally/zenstack/models/integrations.zmodel (1)

7-27: Integration models and relations look structurally sound

The Credential, CalendarConnection, and ProviderCalendar models line up well with User and with each other: foreign keys use the mapped scalar fields, relation names are consistent (including UserDefaultDestinationCalendar), and table/column mappings are coherent. This should give good coverage for join/name‑mapping behavior.

Also applies to: 29-50, 52-87

tests/e2e/apps/rally/zenstack/models/billing.zmodel (1)

4-27: Billing schema is consistent and relationally well-formed

Subscription, SubscriptionStatus, SubscriptionInterval, and PaymentMethod are wired cleanly: FKs to User/Space use mapped IDs with cascade semantics, indices cover main lookup keys, and table/column mappings are coherent. Nothing blocking here from a schema/relations standpoint.

Also applies to: 29-47, 49-60

tests/e2e/apps/rally/zenstack/models/user.zmodel (1)

65-92: User–calendar and session relations are coherently wired

The User model’s relations to Subscription, Space, CalendarConnection, Credential, and ProviderCalendar (Lines 65–87) all line up with the corresponding models: relation names match (UserToSubscription, UserSpaces, UserDefaultDestinationCalendar), and the mapped FK fields (default_destination_calendar_id, etc.) are used consistently. Likewise, the impersonation setup between Session.impersonatedByUser and User.impersonatedSessions via "ImpersonatedSessions" is correctly paired. No changes needed here.

Also applies to: 81-87, 103-119

tests/e2e/apps/rally/zenstack/models/poll.zmodel (1)

5-19: Poll domain schema is well-structured for relational queries

The Poll graph (Poll, Watcher, Participant, Option, Vote, Comment, PollView) is modeled cleanly: FKs and @map usages match the relations, delete behaviors (Cascade/SetNull) are sensible for lifecycle, and the indexes cover primary join and lookup paths (pollId, userId, spaceId, etc.). This should serve well for exercising complex joined queries in the e2e tests.

Also applies to: 21-172

tests/e2e/apps/rally/zenstack/models/licensing.zmodel (1)

1-54: Licensing models and mappings look clean

License, LicenseValidation, and InstanceLicense are straightforward: enums are used consistently, FK from LicenseValidation to License is correctly defined with cascade delete, and table/column mappings are coherent. No changes needed from a schema perspective.

tests/e2e/apps/rally/zenstack/models.ts (1)

1-64: Generated model and enum surface looks consistent

The imports, model $ModelResult<$Schema, "..."> aliases, and enum value/union exports all follow a consistent pattern and match what we’d expect from the generator. Nothing to fix here.

tests/e2e/apps/rally/zenstack/input.ts (1)

1-550: Generated input/args typings are structurally sound

The arg/input aliases and GetPayload definitions are uniformly applied across all models, with consistent use of $Schema, generic arg helpers, and $SimplifiedModelResult. For a generated surface this looks correct and complete.

@ymc9 ymc9 merged commit 94679db into dev Nov 14, 2025
12 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