Skip to content

v0.6.0: Prisma 7 schema compatibility — @map/@@map, @updatedAt, BigInt defaults, enum[] decode, FK resolution - #73

Merged
teetangh merged 8 commits into
mainfrom
feat/prisma7-schema-compat
Jul 2, 2026
Merged

v0.6.0: Prisma 7 schema compatibility — @map/@@map, @updatedAt, BigInt defaults, enum[] decode, FK resolution#73
teetangh merged 8 commits into
mainfrom
feat/prisma7-schema-compat

Conversation

@teetangh

@teetangh teetangh commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Why

The familiarise web app's Prisma 7 schema (5,028 lines, 120 models, 100 enums — BetterAuth @@map-ed tables, BigInt paise money columns, composite-@@id counters) is being synced into the mobile Dart Frog backend. Generating a client from it surfaced six generator/runtime gaps, all fixed here with tests. This is the connector release the mobile schema-sync PR (Practitionist/familiarise_mobile) depends on.

What

Parser & generators

  • Model-level @@map("table")PrismaModel.dbName; generated SQL targets the mapped table (model User { @@map("users") }FROM "users"). Explicit @@map wins over reserved-keyword renames.
  • Field-level @map("column")PrismaField.dbName; flows into @JsonKey, fromJson/toJson keys, and registry columnName (e.g. status AppointmentStatus @map("requestStatus")).
  • Enum bodies: @@map(...) block attributes and value-level attributes are no longer emitted as enum values (previously generated invalid Dart).
  • Composite @@id models (no unique scalar field): delegates omit findUnique/findUniqueOrThrow/update/delete instead of referencing a nonexistent WhereUniqueInput.
  • BigInt @default(0): freezed @Default is impossible (BigInt isn't const) — model params become required with a BigInt.from() fromJson fallback; CreateInput leaves them nullable so the DB default applies.
  • One-to-one FK on the target model (Program.licensedSeatConfig where LicensedSeatConfig.programId owns the @relation): registry now emits isOwner: false with the target's real FK instead of fabricating <fieldName>Id — fixes column tN.id does not exist on nested includes.

Runtime

  • SqlCompiler field→column translation: WHERE / INSERT columns / UPDATE SET / ORDER BY resolve Dart field names through the registry, so typed-delegate CRUD is correct on @map-ed columns end-to-end. Unregistered keys pass through unchanged — legacy JsonQueryBuilder callers using literal column names are unaffected (verified inside AND/OR/NOT recursion too).
  • @updatedAt auto-fill: create/createMany fill it (NOW() on pg/supabase, ISO-8601 param elsewhere); update/updateMany refresh it unless explicitly supplied. Previously every typed create on a table with @updatedAt failed its NOT NULL constraint.
  • PostgresAdapter enum[]/custom array decoding: parses the binary ARRAY wire format and text array literals into List<String?> (NULL elements preserved) instead of returning raw bytes.

Validation

  • 380 unit tests pass (66 → 380; 40 new tests across 7 files cover every change), flutter analyze clean, dart format clean.
  • Live end-to-end against the real 5,028-line production schema on local PostgreSQL 16: full API sweep through the consuming Dart Frog backend — auth on @@map-ed tables, plan CRUD with BigInt paise, @map-ed Consultation.status transitions, enum[] profile reads, nested include through Program → LicensedSeatConfig/CreditPoolConfig. Zero open failures.

Follow-ups (complete-ORM roadmap)

Tracked in #71: interactive transactions #68, nested writes #64, typed include/relation hydration #67, upsert #66, groupBy/aggregate #65, cursor pagination/Json filters #69, connection pooling #70.

Release

Merging does NOT publish. After merge: git tag v0.6.0 && git push origin v0.6.0 → publish.yml OIDC-publishes to pub.dev.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Prisma @map/@@map mappings are honored end-to-end (models/fields → SQL/table/column names).
    • @updatedAt fields are auto-populated on create and refreshed on update.
    • PostgreSQL enum-array columns decode from both binary and text formats.
    • Improved BigInt generation and mapped JSON key support in models.
  • Bug Fixes

    • Enum directive/value parsing corrected.
    • One-to-one relation FK ownership and composite-id delegate generation fixed.
  • Tests

    • Added unit tests for mapping, updatedAt, BigInt, enum arrays, composite-id, SQL compiler.
  • Documentation

    • Changelog updated for v0.6.0.
  • Chores

    • CI integration workflows made manual/guarded.

Kaustav Ghosh and others added 6 commits June 13, 2026 02:07
…legates

- Parse model-level @@Map("table") into PrismaModel.dbName (explicit
  @@Map wins over reserved-keyword renames)
- Parse field-level @Map("column") into PrismaField.dbName (priority:
  explicit @Map > reserved-keyword rename > PascalCase normalization)
- Stop emitting enum block attributes (@@Map) and value-level attributes
  as enum values — previously generated invalid Dart identifiers
- Delegate generator omits findUnique/findUniqueOrThrow/update/delete
  for models whose only identifier is a composite @@id (no
  WhereUniqueInput exists for them)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
BigInt has no const constructor, so freezed @default is impossible:
- Model class: BigInt-with-literal-default fields become required params;
  fromJson supplies the schema default via BigInt.from()
- CreateInput: such fields stay nullable WITHOUT @default (the database
  applies the default)
- Tests cover required/optional/defaulted BigInt fields and @jsonkey
  emission + mapped fromJson/toJson keys for @map-ed fields

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- FieldInfo.isUpdatedAt, emitted by the registry generator from
  @updatedat fields (consumed by the SQL compiler)
- One-to-one relations whose FK lives on the TARGET model (e.g.
  Program.licensedSeatConfig with LicensedSeatConfig.programId owning the
  @relation) now emit isOwner:false with the target's real FK instead of
  fabricating a nonexistent <fieldName>Id column on the parent — fixes
  'column tN.id does not exist' on nested includes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- WHERE keys, INSERT columns, UPDATE SET keys, and ORDER BY keys resolve
  Dart field names to database column names via the registry, making
  typed-delegate CRUD correct on @map-ed columns end-to-end; keys that
  are not registered field names pass through unchanged (legacy
  JsonQueryBuilder callers keep working), including in AND/OR/NOT
- create/createMany fill @updatedat columns (NOW() on pg/supabase,
  ISO-8601 param elsewhere); update/updateMany refresh @updatedat unless
  the caller supplied a value — previously every typed create on a table
  with @updatedat failed its NOT NULL constraint

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
UndecodedBytes was blindly UTF-8 decoded, so custom enum array columns
(e.g. SessionType[]) surfaced as raw wire-format bytes. Now parses the
binary ARRAY wire format (1-D, NULL elements supported) and text array
literals ({A,"c d",NULL}) into List<String?>, falling back to UTF-8 for
scalar enum labels.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Parser captures Prisma @map/@@map and normalizes enums; generators emit mapped table/column names, FieldInfo.isUpdatedAt, BigInt/default handling, and conditional delegate methods for composite-only IDs; SQL compiler and Postgres adapter consume mappings and enum[] parsing; tests and CHANGELOG/pubspec updated.

Changes

Prisma @map/@@map, @updatedAt, BigInt, composite IDs, and enum[] support (v0.6.0)

Layer / File(s) Summary
Prisma Parser: @map/@@map and enum normalization
lib/src/generator/prisma_parser.dart, test/unit/prisma_parser_test.dart
Parser extracts model-level @@map("...") and field-level @map("...") into dbName/tableName, skips block-level attributes inside enum bodies, and strips value-level attributes from enum members. Tests validate mapping precedence and enum normalization.
Schema Registry & FK ownership
lib/src/runtime/schema/schema_registry.dart, lib/src/generator/cb_schema_registry_generator.dart, test/unit/schema_registry_generator_map_test.dart
Adds FieldInfo.isUpdatedAt; generator emits isUpdatedAt: true for @updatedAt fields, resolves FK columns via relation metadata (including non-owner one-to-one detection), and maps FK field identifiers to actual column names. Tests verify table/column mapping and one-to-one ownership.
Model & Input Generation: BigInt defaults and mapped JSON keys
lib/src/generator/cb_model_generator.dart, test/unit/model_generator_bigint_test.dart, test/unit/model_generator_map_jsonkey_test.dart
BigInt deserialization uses BigInt.parse(...) with fallback to parsed schema default when applicable; inputs with BigInt schema defaults avoid Default(...) annotations and are required/non-nullable as appropriate. Field-level @map emits @JsonKey(name: ...) and adjusts fromJson/toJson to use mapped JSON keys.
Delegate Generation: composite-@@id behavior
lib/src/generator/cb_delegate_generator.dart, test/unit/delegate_generator_composite_id_test.dart
Delegate generator computes hasUniqueFields and emits unique-keyed methods (findUnique, findUniqueOrThrow, update, delete, and related helpers) only when non-relation scalar id/unique fields exist, avoiding WhereUniqueInput references for composite-only @@id. Tests cover both composite-only and scalar-unique models.
SQL Compiler: mapped columns and @updatedAt injection
lib/src/runtime/query/sql_compiler.dart, test/unit/sql_compiler_map_test.dart, test/unit/sql_compiler_updated_at_test.dart
Introduces _resolveColumnName(modelName, field) and applies it across WHERE, ORDER BY, CREATE, CREATE MANY, UPDATE, and GROUP BY paths; create/update default and @updatedAt injection check both Dart names and mapped column names. Tests validate mapping, strict model validation, and updatedAt behavior across providers.
PostgreSQL Adapter: enum[] binary/text parsing
lib/src/runtime/adapters/postgres_adapter.dart, test/unit/postgres_array_decode_test.dart
pg.UndecodedBytes handling extended: binary undecoded payloads attempt parsePgBinaryArray and non-binary decode attempts parsePgTextArray; adds parsePgBinaryArray and parsePgTextArray to return List<String?> with proper NULL and quoting behavior. Tests validate binary wire frames and text literal parsing.
Release notes and version bump
CHANGELOG.md, pubspec.yaml
Adds CHANGELOG entry for v0.6.0 documenting mapping, updatedAt, enum array decoding, FK ownership fixes, composite-id delegate behavior; bumps package version to 0.6.0.

Estimated code review effort:
🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related issues:

"🐰 With @map in place and updatedAt kept bright,
enum arrays decode by day and by night,
BigInt defaults parse true and neat,
composite IDs stop claiming unique seats,
v0.6.0 hops forward — tidy and light."

🚥 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 comprehensively summarizes the main features delivered in v0.6.0, covering schema mapping (@map/@@Map), @updatedAt auto-fill, BigInt default handling, enum array decoding, and FK resolution improvements.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/prisma7-schema-compat

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for @map and @@map attributes to map Dart models and fields to database tables and columns, implements auto-fill and refresh behavior for @updatedAt fields, and decodes custom PostgreSQL enum arrays. It also fixes delegate generation for models with only composite identifiers and handles BigInt default values. The review feedback suggests optimizing byte copying in PostgreSQL array decoding, parsing the model body line-by-line to avoid matching commented-out @@map attributes, and using BigInt.parse instead of BigInt.from to prevent precision loss on web platforms.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread lib/src/runtime/adapters/postgres_adapter.dart
Comment thread lib/src/generator/prisma_parser.dart Outdated
Comment thread lib/src/generator/cb_model_generator.dart

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (2)
lib/src/runtime/query/sql_compiler.dart (2)

537-556: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

createMany can mis-bind values to columns when row key order differs

Columns are fixed from firstRow.keys (Line 537-541), but each row’s placeholders are filled from rowData.values (Line 552). If a later row has different key insertion order, values can be written into the wrong columns.

Suggested fix
-    final firstRow = dataList.first as Map<String, dynamic>;
+    final firstRow = dataList.first as Map<String, dynamic>;
+    final orderedKeys = firstRow.keys.toList();
@@
-    for (final row in dataList) {
-      final rowData = row as Map<String, dynamic>;
+    for (final row in dataList) {
+      final rowData = row as Map<String, dynamic>;
       final placeholders = <String>[];
 
-      for (final value in rowData.values) {
+      for (final key in orderedKeys) {
+        if (!rowData.containsKey(key)) {
+          throw ArgumentError('CREATE MANY row is missing key "$key"');
+        }
+        final value = rowData[key];
+        if (value is _RawSql) {
+          placeholders.add(value.sql);
+          continue;
+        }
         placeholders.add(_placeholder(paramIndex++));
         values.add(value);
         types.add(_inferArgType(value));
       }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/src/runtime/query/sql_compiler.dart` around lines 537 - 556, The current
createMany implementation builds the columns from firstRow.keys but fills
placeholders using rowData.values, which can mis-align when map key orders
differ; change the per-row loop to iterate over the canonical column key list
(capture firstRowKeys = firstRow.keys.toList() after resolving names) and for
each columnKey read value = rowData[columnKey] (use null if absent) before
adding _placeholder(paramIndex++), values.add(value) and
types.add(_inferArgType(value)); keep existing helpers (_resolveColumnName,
_quoteIdentifier, _placeholder, _inferArgType) and variables (columns,
valueSets, values, types, paramIndex, placeholders) but replace reliance on
rowData.values with indexed lookups by the canonical key list to ensure stable
binding.

520-569: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

createMany skips @updatedAt/schema defaults, breaking parity with create

Line 520 onward compiles rows as-is, but never applies the same default/@updatedAt enrichment done in Line 456-479 for single-row create. For models with non-null @updatedAt (no DB default), createMany can fail at insert time unless callers manually provide timestamps in every row.

Suggested fix
   SqlQuery _compileCreateManyQuery(JsonQuery query) {
     final args = query.args.arguments ?? {};
@@
-    final tableName = _resolveTableName(query.modelName);
-    final firstRow = dataList.first as Map<String, dynamic>;
+    final tableName = _resolveTableName(query.modelName);
+    final model = (schema ?? schemaRegistry).getModel(query.modelName);
+    final rows = dataList.cast<Map<String, dynamic>>();
+
+    if (model != null) {
+      for (final row in rows) {
+        for (final field in model.fields.values) {
+          if (row.containsKey(field.name) || row.containsKey(field.columnName)) {
+            continue;
+          }
+          if (field.defaultValue == 'uuid()' || field.defaultValue == 'cuid()') {
+            if (provider == 'postgresql' || provider == 'supabase') {
+              row[field.name] = const _RawSql('gen_random_uuid()');
+            }
+          } else if (field.defaultValue == 'now()' || field.isUpdatedAt) {
+            if (provider == 'postgresql' || provider == 'supabase') {
+              row[field.name] = const _RawSql('NOW()');
+            } else {
+              row[field.name] = DateTime.now().toUtc().toIso8601String();
+            }
+          }
+        }
+      }
+    }
+
+    final firstRow = rows.first;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/src/runtime/query/sql_compiler.dart` around lines 520 - 569, The
createMany compiler (_compileCreateManyQuery) currently builds rows as-is and
must apply the same schema default and `@updatedAt` enrichment that the single-row
create path does (the logic around lines 456–479); modify
_compileCreateManyQuery to iterate each row, run the same default/@updatedAt
enrichment used by the single-row create (or extract that enrichment into a
helper and call it for every row) before computing columns, placeholders and
types so any non-null `@updatedAt` or other schema defaults are populated and
included in the INSERT columns/values. Ensure the enriched row may add new keys
(so columns list is derived after enrichment or merged across rows), update
values/types/placeholder generation accordingly, and reuse helpers like
_resolveColumnName, _quoteIdentifier and _inferArgType when building the final
SqlQuery.
🧹 Nitpick comments (2)
lib/src/runtime/adapters/postgres_adapter.dart (1)

277-312: 📐 Maintainability & Code Quality | 💤 Low value

Binary array parser looks correct; consider documenting the multi-dimensional limitation.

The bounds checking is thorough and the fallback to null (triggering UTF-8 scalar decode) is appropriate for non-array payloads. The ndim != 1 check on line 291 silently falls back for multi-dimensional arrays—this is fine for the current enum[] use case but worth noting in the doc comment if multi-dim arrays might appear in future.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/src/runtime/adapters/postgres_adapter.dart` around lines 277 - 312,
Update the doc comment for parsePgBinaryArray to state it only supports
one-dimensional PostgreSQL binary ARRAY wire format and will return null for
multi-dimensional arrays (see the ndim != 1 check and early return), and mention
that callers should fall back to scalar UTF-8 decoding when null is returned;
keep the existing behavior but add this note to the method-level documentation
so future readers understand the ndim limitation.
test/unit/schema_registry_generator_map_test.dart (1)

68-113: 📐 Maintainability & Code Quality | ⚡ Quick win

Add a mapped-FK regression in one-to-one relation resolution tests.

This scenario currently uses programId without @map, so it won’t catch FK column-name mapping regressions. Add a case with programId @Map("program_id") and assert emitted foreignKey: 'program_id'.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/unit/schema_registry_generator_map_test.dart` around lines 68 - 113, Add
a regression test variant that covers mapped foreign keys in one-to-one
resolution: modify or add to the test in schema_registry_generator_map_test.dart
(the group 'CbSchemaRegistryGenerator one-to-one FK resolution' / test 'FK on
the target model emits non-owner relation with real FK') to include a schema
where LicensedSeatConfig declares "programId `@map`('program_id')" and then assert
that CbSchemaRegistryGenerator(parsed).generate() (after flatten) emits
RelationInfo.oneToOne with foreignKey: 'program_id' for the non-owner side and
does not fabricate 'licensedSeatConfigId'; this ensures the generator uses the
mapped column name rather than the raw field name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Around line 23-25: The release note for PostgresAdapter's enum[] / custom
array decoding uses the wrong nullable type; update the text to reflect that
NULL elements are preserved by changing the type mention from List<String> to
List<String?> in the CHANGELOG entry describing "Custom enum array columns (e.g.
`SessionType[]`) now decode to ...". Keep the surrounding sentence intact and
ensure the example still references handling of binary ARRAY wire format and
text array literals with NULL elements preserved.

In `@lib/src/generator/cb_schema_registry_generator.dart`:
- Around line 143-149: The relation back-reference lookup (the targetBack
assignment using targetModel.fields.where(...).firstOrNull and the similar
lookup later) only filters by type and flags and can pick the wrong relation
when multiple relations exist between the same models; update those filters to
also match the relation name from the source relation (e.g., require
f.relationName == relation.relationName, handling nullable relationName equality
correctly so null==null still matches) so the FK ownership (isOwner) is derived
from the exact relation pair rather than the first type match.
- Around line 135-137: The code currently assigns relation field identifiers
(ownFk / values returned by _findForeignKeyOnModel) directly into
RelationInfo.foreignKey, but downstream SQL expects the actual DB column name
(respecting `@map`). After computing ownFk (and in any other place you call
_findForeignKeyOnModel), resolve that field identifier to the model's mapped
column name before assigning to RelationInfo.foreignKey: find the corresponding
Field object on model (e.g., model.fields.firstWhere(f => f.name == ownFk)),
read its mapped/database column name property (the `@map` equivalent on that
Field) and use that DB column name; if no mapping exists fall back to the field
name. Ensure the same resolution is applied wherever RelationInfo.foreignKey is
set.

---

Outside diff comments:
In `@lib/src/runtime/query/sql_compiler.dart`:
- Around line 537-556: The current createMany implementation builds the columns
from firstRow.keys but fills placeholders using rowData.values, which can
mis-align when map key orders differ; change the per-row loop to iterate over
the canonical column key list (capture firstRowKeys = firstRow.keys.toList()
after resolving names) and for each columnKey read value = rowData[columnKey]
(use null if absent) before adding _placeholder(paramIndex++), values.add(value)
and types.add(_inferArgType(value)); keep existing helpers (_resolveColumnName,
_quoteIdentifier, _placeholder, _inferArgType) and variables (columns,
valueSets, values, types, paramIndex, placeholders) but replace reliance on
rowData.values with indexed lookups by the canonical key list to ensure stable
binding.
- Around line 520-569: The createMany compiler (_compileCreateManyQuery)
currently builds rows as-is and must apply the same schema default and
`@updatedAt` enrichment that the single-row create path does (the logic around
lines 456–479); modify _compileCreateManyQuery to iterate each row, run the same
default/@updatedAt enrichment used by the single-row create (or extract that
enrichment into a helper and call it for every row) before computing columns,
placeholders and types so any non-null `@updatedAt` or other schema defaults are
populated and included in the INSERT columns/values. Ensure the enriched row may
add new keys (so columns list is derived after enrichment or merged across
rows), update values/types/placeholder generation accordingly, and reuse helpers
like _resolveColumnName, _quoteIdentifier and _inferArgType when building the
final SqlQuery.

---

Nitpick comments:
In `@lib/src/runtime/adapters/postgres_adapter.dart`:
- Around line 277-312: Update the doc comment for parsePgBinaryArray to state it
only supports one-dimensional PostgreSQL binary ARRAY wire format and will
return null for multi-dimensional arrays (see the ndim != 1 check and early
return), and mention that callers should fall back to scalar UTF-8 decoding when
null is returned; keep the existing behavior but add this note to the
method-level documentation so future readers understand the ndim limitation.

In `@test/unit/schema_registry_generator_map_test.dart`:
- Around line 68-113: Add a regression test variant that covers mapped foreign
keys in one-to-one resolution: modify or add to the test in
schema_registry_generator_map_test.dart (the group 'CbSchemaRegistryGenerator
one-to-one FK resolution' / test 'FK on the target model emits non-owner
relation with real FK') to include a schema where LicensedSeatConfig declares
"programId `@map`('program_id')" and then assert that
CbSchemaRegistryGenerator(parsed).generate() (after flatten) emits
RelationInfo.oneToOne with foreignKey: 'program_id' for the non-owner side and
does not fabricate 'licensedSeatConfigId'; this ensures the generator uses the
mapped column name rather than the raw field name.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e181cc93-56c0-4cb8-989a-e4db3286e503

📥 Commits

Reviewing files that changed from the base of the PR and between b074e02 and 975949b.

📒 Files selected for processing (17)
  • CHANGELOG.md
  • lib/src/generator/cb_delegate_generator.dart
  • lib/src/generator/cb_model_generator.dart
  • lib/src/generator/cb_schema_registry_generator.dart
  • lib/src/generator/prisma_parser.dart
  • lib/src/runtime/adapters/postgres_adapter.dart
  • lib/src/runtime/query/sql_compiler.dart
  • lib/src/runtime/schema/schema_registry.dart
  • pubspec.yaml
  • test/unit/delegate_generator_composite_id_test.dart
  • test/unit/model_generator_bigint_test.dart
  • test/unit/model_generator_map_jsonkey_test.dart
  • test/unit/postgres_array_decode_test.dart
  • test/unit/prisma_parser_test.dart
  • test/unit/schema_registry_generator_map_test.dart
  • test/unit/sql_compiler_map_test.dart
  • test/unit/sql_compiler_updated_at_test.dart

Comment thread CHANGELOG.md
Comment thread lib/src/generator/cb_schema_registry_generator.dart Outdated
Comment thread lib/src/generator/cb_schema_registry_generator.dart Outdated
- registry generator: emit DB column names for relation foreign keys
  (@map-ed FK scalars previously produced invalid JOINs) and bind
  relations by @relation("name") when multiple relations link the same
  model pair — this corrected two wrong bindings in the consuming app's
  schema (User.reportsReceived, User.erasureRequestsProcessed)
- parser: @@Map matching is line-based with comments stripped, so a
  commented-out // @@Map("x") no longer remaps the table
- model generator: BigInt defaults emit BigInt.parse('<literal>')
  (BigInt.from rounds through a JS double on web)
- postgres adapter: decode binary arrays as views over the original
  buffer (no per-element copies)
- changelog: enum[] decode returns List<String?> (NULLs preserved)

Part of #73

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/src/generator/cb_model_generator.dart (1)

353-357: 📐 Maintainability & Code Quality | ⚡ Quick win

Stale comment references removed code path.

The comment on line 355 still says "BigInt.from" but the actual fromJson fallback (line 147) now uses BigInt.parse.

✏️ Proposed fix
       if (hasScalarDefault && dartType == 'BigInt') {
-        // BigInt has no const constructor → `@Default` is impossible; the
-        // fromJson fallback (BigInt.from) supplies the schema default
+        // BigInt has no const constructor → `@Default` is impossible; the
+        // fromJson fallback (BigInt.parse) supplies the schema default
         type = dartType;
         isRequired = true;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/src/generator/cb_model_generator.dart` around lines 353 - 357, The
comment in the BigInt default branch is stale: update the comment in the
hasScalarDefault && dartType == 'BigInt' block (the block that sets type =
dartType and isRequired = true) to reference the actual fromJson fallback
implementation (which uses BigInt.parse in the fromJson code path), i.e.,
replace "BigInt.from" with "BigInt.parse" and adjust wording to match the
current fallback behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@lib/src/generator/cb_model_generator.dart`:
- Around line 353-357: The comment in the BigInt default branch is stale: update
the comment in the hasScalarDefault && dartType == 'BigInt' block (the block
that sets type = dartType and isRequired = true) to reference the actual
fromJson fallback implementation (which uses BigInt.parse in the fromJson code
path), i.e., replace "BigInt.from" with "BigInt.parse" and adjust wording to
match the current fallback behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a99d3ee7-bf67-42fe-a1f4-9d3c91146b8e

📥 Commits

Reviewing files that changed from the base of the PR and between 975949b and 411257f.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • lib/src/generator/cb_model_generator.dart
  • lib/src/generator/cb_schema_registry_generator.dart
  • lib/src/generator/prisma_parser.dart
  • lib/src/runtime/adapters/postgres_adapter.dart
  • test/unit/model_generator_bigint_test.dart
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • lib/src/generator/prisma_parser.dart
  • lib/src/runtime/adapters/postgres_adapter.dart
  • test/unit/model_generator_bigint_test.dart

- Fix unparseable test description in model_generator_bigint_test.dart
  (unescaped single quotes broke dart format, analyzer, and all unit
  test jobs)
- Disable push/pull_request triggers on MongoDB and MySQL integration
  workflows: adapters are not implemented yet (ci.yml already excludes
  them); keep workflow_dispatch/workflow_call for manual runs
- Fix Supabase workflow secrets check: 'exit 0' did not skip subsequent
  steps, so prisma migrate deploy failed on empty SUPABASE_DIRECT_URL.
  Gate every step on the check step's should-run output instead

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.github/workflows/supabase-integration.yml (1)

124-129: 📐 Maintainability & Code Quality

Consider upgrading codecov-action and pinning action versions.

The static analysis tool flagged that codecov/codecov-action@v3 has a runner that is too old for GitHub Actions. Additionally, actions are not pinned to commit SHAs, which is a supply-chain security best practice.

These are pre-existing issues not introduced by this PR, but worth addressing in a follow-up to prevent potential CI failures and improve security posture.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/supabase-integration.yml around lines 124 - 129, The
GitHub Actions step "Upload coverage" currently uses codecov/codecov-action@v3
which is flagged as using an outdated runner and is not pinned to a commit SHA;
update the step to a newer, runner-compatible major release of the action (e.g.,
v4) and replace the tag with a full commit SHA to pin the action (uses:
codecov/codecov-action@<full-commit-sha>), or alternatively use the action's
recommended pinned reference, and run the workflow to verify compatibility with
the if: condition and the files/flags inputs remain unchanged.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/supabase-integration.yml:
- Around line 124-129: The GitHub Actions step "Upload coverage" currently uses
codecov/codecov-action@v3 which is flagged as using an outdated runner and is
not pinned to a commit SHA; update the step to a newer, runner-compatible major
release of the action (e.g., v4) and replace the tag with a full commit SHA to
pin the action (uses: codecov/codecov-action@<full-commit-sha>), or
alternatively use the action's recommended pinned reference, and run the
workflow to verify compatibility with the if: condition and the files/flags
inputs remain unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7380f9c1-4da0-44b0-a450-071e5acc5d0c

📥 Commits

Reviewing files that changed from the base of the PR and between 411257f and c5e6fa3.

📒 Files selected for processing (4)
  • .github/workflows/mongodb-integration.yml
  • .github/workflows/mysql-integration.yml
  • .github/workflows/supabase-integration.yml
  • test/unit/model_generator_bigint_test.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/unit/model_generator_bigint_test.dart

@teetangh teetangh self-assigned this Jun 12, 2026
@teetangh
teetangh merged commit 67df68e into main Jul 2, 2026
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.

1 participant