pub trait Statement: Sealed {
type Dialect: Dialect;
type Table: Table;
// Provided methods
fn to_sql(&self, _dialect: Self::Dialect) -> (String, Vec<Value>) { ... }
fn returning<Sel, Idx>(self, sel: Sel) -> Returning<Self, Sel>
where Self: Sized,
Self::Dialect: SupportsReturning,
Sel: Selection<WrittenTable<Self::Table>, Idx> { ... }
}Expand description
A statement that writes to a single table. Sealed: the three writing
statements are the whole set, and Returning is defined against this
rather than against each of them.
Required Associated Types§
Provided Methods§
Sourcefn to_sql(&self, _dialect: Self::Dialect) -> (String, Vec<Value>)
fn to_sql(&self, _dialect: Self::Dialect) -> (String, Vec<Value>)
The dialect is an argument for the reason Select::to_sql’s is.
Sourcefn returning<Sel, Idx>(self, sel: Sel) -> Returning<Self, Sel>where
Self: Sized,
Self::Dialect: SupportsReturning,
Sel: Selection<WrittenTable<Self::Table>, Idx>,
fn returning<Sel, Idx>(self, sel: Sel) -> Returning<Self, Sel>where
Self: Sized,
Self::Dialect: SupportsReturning,
Sel: Selection<WrittenTable<Self::Table>, Idx>,
RETURNING, on whichever of the three this is. The clause is the
same clause. A distinct type rather than Self with a flag set: the
execution layer needs Sel’s concrete type to know what to decode a
returned row into, and an optional field would erase it.
The selection is checked against WrittenTable, which is this
statement’s own row.
Known limitation: SQL’s RETURNING reaches further. A scalar
subquery there is the deferral
Select::contains states, and the
joined columns an UPDATE .. FROM / DELETE .. USING lets it name
need those clauses, which aren’t built either. Bind this statement as
a CTE body (cte::with) and join from the outer
query instead: that is checked, and the write and the read it feeds
stay one statement.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".