Skip to main content

InsertStmtKind

Trait InsertStmtKind 

Source
pub trait InsertStmtKind {
    type StmtKind;
}
Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Expand description

Maps an InsertStatement Values shape to the statement-kind marker that should be used when type-checking that statement’s RETURNING clause.

This is what makes RETURNING old(col) accept INSERT ... ON CONFLICT ... DO UPDATE (where the marker is InsertStmtWithOnConflictDoUpdate, for which Nullable<Old<C>> is a valid RETURNING element) but reject plain INSERT (where the marker is InsertStmtWithoutOnConflictDoUpdate, for which Old<C> does not implement SelectableExpression).

The trait is sealed in spirit — it only has impls for the values shapes diesel itself produces — but it is exposed publicly under the i-implement-a-third-party-backend-and-opt-into-breaking-changes feature so third-party backends that introduce new values shapes can add their own impls.

Required Associated Types§

Source

type StmtKind

The statement-kind marker (see e.g. InsertStmtWithoutOnConflictDoUpdate, InsertStmtWithOnConflictDoUpdate) used as the StmtKind parameter of ReturningQuerySource for INSERT statements with this Values shape.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, Tab> InsertStmtKind for ValuesClause<T, Tab>

Source§

impl<V, Tab, QId, const STABLE_QUERY_ID: bool> InsertStmtKind for BatchInsert<V, Tab, QId, STABLE_QUERY_ID>