You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b4eee45
Browse filesBrowse the repository at this point in the historyBrowse files
Complete the read side of FR-024 §7 (#213 shipped the write/schema half). A
write-through entity (writable table source + read-only replica view source +
derived origin.* fields) now generates a hybrid read/write surface:
- The entity file declares the `.existing()` replica view alongside the write
table, plus a Zod read schema whose z.infer IS the read type <Entity> — it
carries the derived fields the write table omits. z.infer (not Drizzle
InferSelectModel/`$inferSelect`) because a Drizzle view is not a Table and
SQLite views don't expose `$inferSelect`; the schema nullability mirrors the
view columns, like a projection.
- Reads (findById/list/reverse-finders) SELECT from the view; writes
(create/update/delete) target the table; create/update re-read the row
through the view by the full PK so the returned <Entity> has the derived
fields (read-your-writes). Insert/Update stay derived-free (#213).
- The scaffold-and-own reference generators (meta init) delegate the
write-through variant to the engine composer, so the default consumer path
is not a silent no-op.
Shared renderExistingViewDecl + renderViewReadZodObject helpers back both
projections and write-through entities (projection output byte-identical).
Gated by a tsc-compile test of the real generated output on both dialects (the
read type + query code type-check end-to-end) + a real-Postgres re-read
round-trip (a row written to the table reads back through the view with the
derived field). An xhigh review caught 5 issues, all fixed: a composite-PK
re-read keying on only the first PK column; a TPH-base + write-through
duplicate `export type <Base>`; the reference generators silently no-op'ing
write-through; a lost read-type JSDoc; and the dbType-block duplication.
TS-only (ADR-0015 — schema/codegen is per-port); the other four ports' ORM/DTO
generators are the tracked cross-port follow-up.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGQ7oSuNcjhsMHWwZzhBwr
Completes the read side of the FR-024 §7 entity read-view (#213 shipped the write/schema half — the write table excludes derived `origin.*` fields and the replica view is emitted + migrate-converged). A **write-through entity** (a writable `table` source + a read-only replica `view` source + derived fields) now generates a hybrid read/write surface in TypeScript:
13
+
14
+
- The entity file declares the `.existing()` replica **view** alongside the write table, plus a Zod read schema whose `z.infer`**is** the read type `<Entity>` — carrying the derived fields the write table omits (`z.infer`, not Drizzle `InferSelectModel`/`$inferSelect`, because a Drizzle view is not a Table and SQLite views don't expose `$inferSelect`; the read schema's nullability mirrors the view columns, exactly like a projection).
15
+
- Generated **reads** (`find<Entity>ById` / `list<Plural>` / reverse finders) SELECT from the view; **writes** (`create` / `update` / `delete`) target the table; a create/update **re-reads** the row through the view by primary key (keyed on the full PK) so the returned `<Entity>` carries the derived fields (read-your-writes). Insert/Update stay derived-free (#213).
16
+
- The scaffold-and-own reference generators (`meta init`) delegate the write-through variant to the engine composer (like the projection/TPH variants), so the default consumer path is not a silent no-op.
17
+
18
+
Shared `renderExistingViewDecl` + `renderViewReadZodObject` helpers now back both projections and write-through entities (projection output byte-identical). Gated by a `tsc`-compile test of the real generated output on both dialects + a real-Postgres re-read round-trip. **TS-only** (ADR-0015 — schema/codegen is per-port); the other four ports' ORM/DTO generators are the tracked cross-port follow-up.
19
+
10
20
### #207 — projection row-scope `@filter` (a view-level WHERE)
11
21
12
22
A projection (`object.projection`) can now declare a row-scope `@filter` — a portable `attr.filter` object (`eq`/`ne`/`gt`/`gte`/`lt`/`lte`/`like`/`in`/`isNull` with `and`/`or`, desugared to canonical `{ field: { op: value } }` at parse time) selecting which rows the derived view returns. It lowers to an outer SQL `WHERE`, the metadata-managed way to express soft-delete / status / type views instead of a hand-written unmanaged view (which is drift, invisible to `verify --db`). Placement mirrors `origin.aggregate @filter` exactly: a `filter`-subtype attr on `object.projection` (the predicate is a LOGICAL derivation, so it lives on the object, not on `source.rdb` — it survives non-RDB lowerings).
0 commit comments