Skip to main content

NestedWriteOp

Enum NestedWriteOp 

Source
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

§relation: String

Name of the relation on the parent model.

§target_table: String

Target child table.

§foreign_key: String

FK column on the child table that references the parent’s PK.

§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

§relation: String

Name of the relation on the parent model.

§pk: FilterValue

Primary key of the child row to connect.

Implementations§

Source§

impl NestedWriteOp

Source

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

Source§

fn clone(&self) -> NestedWriteOp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NestedWriteOp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more