pub enum NestedWriteOp {
Create {
relation: String,
target_table: String,
foreign_key: String,
payload: Vec<Vec<(String, FilterValue)>>,
},
Connect {
relation: String,
pk: FilterValue,
},
}Expand description
Model-erased nested write op used by CreateOperation::with(...).
The type-parameterized NestedWrite above is keyed on the parent
model and doesn’t compose across heterogeneous child types — a
CreateOperation<E, User>.with(posts_write) needs to carry child
writes for a different model (Post) than the parent, so User’s
NestedWrite<User> can’t encode them. This sibling enum drops the
model type parameter and carries only the runtime metadata the
execution path actually needs: the target table, the foreign-key
column on that table, and the raw child-column payload.
Emitted by the codegen’s per-relation create() / connect()
helpers on user::posts::*. Payloads are a nested
Vec<Vec<(String, FilterValue)>> rather than a strongly-typed
CreateInput because the derive path doesn’t currently emit a
CreateInput struct per model — see the task docs for the trade-off
and the upgrade path.
Variants§
Create
Create children whose FK column points at the parent’s PK.
relation is retained for diagnostics/debugging; the executor
only needs target_table, foreign_key, and payload.
Fields
payload: Vec<Vec<(String, FilterValue)>>One Vec<(column, value)> per child row. The FK column +
parent PK are appended by NestedWriteOp::execute.
Connect
Connect an existing child by its PK — not yet implemented.
Connect on a HasMany/HasOne relation translates to
UPDATE <child_table> SET <fk> = <parent_pk> WHERE <child_pk> = <pk>,
but plumbing the child-PK column name through to execute time
needs more relation metadata than the current codegen surface
exposes. The variant carries its data so callers can still
build it, but NestedWriteOp::execute returns
QueryError::internal until the metadata is wired.
Fields
pk: FilterValuePrimary key of the child row to connect.
Implementations§
Source§impl NestedWriteOp
impl NestedWriteOp
Sourcepub async fn execute<E>(
self,
engine: &E,
parent_pk: &FilterValue,
) -> QueryResult<()>where
E: QueryEngine,
pub async fn execute<E>(
self,
engine: &E,
parent_pk: &FilterValue,
) -> QueryResult<()>where
E: QueryEngine,
Execute this nested write inside engine, using parent_pk
as the foreign-key value to splice into each child row.
For Create, this emits one INSERT INTO <target_table> (...)
per child, appending the FK column + parent PK to whatever
columns/values the caller supplied.
Trait Implementations§
Source§impl Clone for NestedWriteOp
impl Clone for NestedWriteOp
Source§fn clone(&self) -> NestedWriteOp
fn clone(&self) -> NestedWriteOp
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more