pub struct Values {
pub query: Option<Expr>,
pub rows: Vec<ValuesRow>,
}Expand description
Where the rows an INSERT adds come from.
Two shapes, in priority order — a query to insert from, or a list of rows:
INSERT INTO t (cols) VALUES ( expr [, ...] ) [, ...]
INSERT INTO t (cols) querybob has a third: with neither it writes DEFAULT VALUES. That is not done here,
because an absent clause has to render nothing, and because the spelling is not
shared — PostgreSQL and SQLite say DEFAULT VALUES, MySQL says VALUES () or
() VALUES (). An INSERT query type checks is_empty and
writes its own dialect’s spelling.
Fields§
§query: Option<Expr>A query to insert the results of. Takes priority over
rows, because INSERT … VALUES … SELECT … is not a thing:
the two are alternatives, and a query having been set is the more
deliberate act.
rows: Vec<ValuesRow>One entry per row.
Implementations§
Source§impl Values
impl Values
Sourcepub fn from_query(query: impl IntoExpr) -> Self
pub fn from_query(query: impl IntoExpr) -> Self
Insert the results of query.
Sourcepub fn append_values(&mut self, values: impl IntoExprList)
pub fn append_values(&mut self, values: impl IntoExprList)
Append one row.
An empty row is ignored: VALUES () is not valid in PostgreSQL or SQLite,
and an insert with no values wants its dialect’s “default row” spelling
instead.