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 f86ac4e
Browse filesBrowse the repository at this point in the historyBrowse files
feat(#214): entity read-view codegen READ half — Python port
Fan the FR-024 §7 read-half (TS reference b4eee45) out to the Python port. It
splits into a codegen half and a runtime half (schema stays TS-owned, ADR-0015).
Shared metadata predicates (SSOT, mirror Java/Kotlin/C#):
- MetaField.is_derived() — the field carries an origin.* child (own-only; matched
by type string so the core field module needs no persistence-layer import).
- MetaObject.is_write_through() — owns BOTH a writable-kind and a read-only-kind
source.rdb (role-agnostic own-source classification — a replica view carries
@ROLE:replica, so no primary-role accessor).
Codegen:
- entity_model.py: <Name>Create and <Name>Patch EXCLUDE derived fields (view-
computed, not client input); the read model still carries them.
- router_generator.py + filter_allowlist_generator.py: a write-through entity is
writable, so both its CRUD router AND the filter allowlist its router imports are
emitted — via an order-independent gate (else a view-source-first write-through
router imports a never-generated allowlist module → FastAPI startup crash).
Runtime (ObjectManager — the analogue of the TS queries-file):
- reads (find_many / find_by_id / count) route to the replica VIEW (carrying the
derived columns) for a write-through entity, else the entity's own source.
- writes (create / update) target the table with derived fields excluded from BOTH
the INSERT/UPDATE column set (a read-modify-write round-trip POSTing back the read
model must not try to write a view-computed column) AND the RETURNING set (the
table has no such column), then RE-READ the row through the view by PK so the
returned dict carries the derived fields (read-your-writes). delete is unchanged.
- vanilla entities and projections are byte-identical (they have no derived fields /
are not write-through).
Gated by test_write_through.py (read model carries derived, Create/Patch exclude
it, router + filter-allowlist emitted regardless of source order) and
test_object_manager_write_through.py (a fake driver asserts reads→view,
writes→table with derived excluded from INSERT/UPDATE + RETURNING, and the by-PK
view re-read). A high-effort review caught the filter-allowlist gate coupling and
the write-column-set derived leak (both fixed above).
Single-PK is the documented ObjectManager scope; a row-scoped replica view that
does not surface a just-written row falls back to the table row (its derived fields
absent) — an accepted edge for the 1:1-replica common case.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGQ7oSuNcjhsMHWwZzhBwr
0 commit comments