ogar-emitter: add write_adapter — the CRUD write twin of emit_projection_adapters#225
Merged
Merged
Conversation
…ion_adapters The read arm (`emit_projection_adapters`, `projection_adapter.rs`) generates real `impl From<Row> for Domain` read projections. There was no Core write equivalent: the only write-side emitter here, `emit_do_adapters`, is deliberately signature-only (`unimplemented!()` bodies — thinking lives upstream). A CRUD statement is a mechanical persistence leaf, exactly the regular, falsifiable body the read arm already proves is emittable. This promotes the write emitter (prototyped + proven in the medcare-rs consumer) into the Core, so consumers stop carrying their own copy — the Core-first home, matching the read arm. `write_adapter.rs`: - `WriteValue` / `WriteColumn` (+ typed constructors: bind / lit / bind_expr / bind_cast / bind_opt_cast / bind_clone / bind_bool_flag — the write inverse of the read arm's `FieldSource` variants). - `InsertClass` + `emit_insert_adapters` — `INSERT … VALUES … last_insert_id`. - `UpdateClass` + `SoftDeleteClass` + `emit_update_adapters` — `UPDATE … SET … WHERE id = ?` (with an optional `COALESCE(<col>,0)=0` soft-delete filter) and the `SET <flag>=1, <date>=NOW()` tombstone. Both `DbResult<()>`. Corpus-agnostic (only typed recipes in; no domain data). Deterministic (recipe order preserved) so a consumer byte-guards its committed generated file against a fresh emit. Generic vs the medcare prototype: the soft-delete columns and the not-deleted filter column are parameterized (`flag_column` / `date_column` / `not_deleted_column`), not hardcoded to `pf_*`. 6 self-contained tests over a synthetic `t_event` recipe (SQL/bind consistency, id-bind-last + soft-delete filter, filter toggle, tombstone shape, multi-line doc, determinism). `cargo test -p ogar-emitter` 45/45; `cargo clippy -p ogar-emitter --all-targets -- -D warnings` exit 0. (do_adapter.rs left untouched — it carries a pre-existing rustfmt-version-skew diff unrelated to this change; OGAR CI gates on `cargo test`, not fmt.) Follow-up: medcare-rs refactors its `insert_codegen` to consume these types instead of its local copy (the consumer PR, once this lands on OGAR main). Generated by Claude Code.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_37f4954b-40ec-46ec-8c26-c73882d2f667) |
AdaWorldAPI
marked this pull request as ready for review
July 22, 2026 02:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The read arm (
emit_projection_adapters,projection_adapter.rs) generates realimpl From<Row> for Domainread projections. There was no Core write equivalent: the only write-side emitter here,emit_do_adapters, is deliberately signature-only (unimplemented!()bodies — thinking lives upstream). A CRUD statement is a mechanical persistence leaf, exactly the regular, falsifiable body the read arm already proves is emittable.This promotes the write emitter (prototyped + proven in the medcare-rs consumer across MedCare PRs #233/#234/#235) into the Core, so consumers stop carrying their own copy — the Core-first home, matching the read arm.
write_adapter.rsWriteValue/WriteColumn+ typed constructors:bind/lit/bind_expr/bind_cast/bind_opt_cast/bind_clone/bind_bool_flag— the write inverse of the read arm'sFieldSourcevariants.InsertClass+emit_insert_adapters—INSERT … VALUES … last_insert_id.UpdateClass+SoftDeleteClass+emit_update_adapters—UPDATE … SET … WHERE id = ?(with an optionalCOALESCE(<col>,0)=0soft-delete filter) and theSET <flag>=1, <date>=NOW()tombstone. BothDbResult<()>.Corpus-agnostic (only typed recipes in; no domain data). Deterministic (recipe order preserved) so a consumer byte-guards its committed generated file against a fresh emit. Generic vs the medcare prototype: the soft-delete columns and the not-deleted filter column are parameterized (
flag_column/date_column/not_deleted_column), not hardcoded topf_*.Verified
t_eventrecipe (SQL/bind consistency, id-bind-last + soft-delete filter, filter toggle, tombstone shape, multi-line doc, determinism).cargo test -p ogar-emitter→ 45/45.cargo clippy -p ogar-emitter --all-targets -- -D warnings→ exit 0.do_adapter.rsleft untouched — it carries a pre-existing rustfmt-version-skew diff unrelated to this change; OGAR CI gates oncargo test, not fmt.Follow-up
medcare-rs refactors its
insert_codegento consume these types instead of its local copy (the consumer PR, once this lands on OGAR main).🤖 Generated with Claude Code