pub struct InsertQuery {
pub with: With,
pub or: Option<Or>,
pub table: TableRef,
pub values: Values,
pub upserts: Vec<ConflictClause>,
pub returning: Returning,
}Expand description
A SQLite INSERT.
From https://www.sqlite.org/lang_insert.html:
[ WITH [ RECURSIVE ] common-table-expression [, ...] ]
INSERT [ OR { ROLLBACK | ABORT | REPLACE | FAIL | IGNORE } ]
INTO [ schema. ] table [ AS alias ] [ ( column [, ...] ) ]
{ VALUES ( expr [, ...] ) [, ...] [ upsert-clause ]
| select-stmt [ upsert-clause ]
| DEFAULT VALUES }
[ RETURNING result-column [, ...] ]DEFAULT VALUES is the alternative Values cannot represent — an absent
clause has to render nothing — so an empty Values is what DEFAULT VALUES
is here, and this query writes the keywords itself. Note from the grammar that
DEFAULT VALUES admits no upsert-clause; a row of defaults conflicts with
nothing worth updating, and SQLite refuses the combination.
A source select-stmt with an upsert-clause after it must have a WHERE,
even a trivial one, or the parser reads the ON as the start of a join
condition. That is SQLite’s rule, not this type’s, and it is left to the parser
to say so — with an unusually clear message.
Fields§
§with: WithWITH ….
or: Option<Or>OR REPLACE and friends. None is the default, ABORT.
table: TableRefThe target: table, optional alias, and the insert column list.
values: ValuesThe rows, or the query to insert the results of. Empty means
DEFAULT VALUES.
upserts: Vec<ConflictClause>The upsert-clause list. SQLite 3.35 and later accept several, tried in
order, and only the last may omit its conflict target.
returning: ReturningRETURNING …. SQLite 3.35 and later.
Implementations§
Source§impl InsertQuery
impl InsertQuery
Sourcepub fn new() -> InsertQuery
pub fn new() -> InsertQuery
An INSERT with nothing set yet.
Sourcepub fn apply(&mut self, mods: impl Mod<InsertQuery>)
pub fn apply(&mut self, mods: impl Mod<InsertQuery>)
Apply more mods to an existing query.
Trait Implementations§
Source§impl Clone for InsertQuery
impl Clone for InsertQuery
Source§fn clone(&self) -> InsertQuery
fn clone(&self) -> InsertQuery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InsertQuery
impl Debug for InsertQuery
Source§impl Default for InsertQuery
impl Default for InsertQuery
Source§fn default() -> InsertQuery
fn default() -> InsertQuery
Source§impl Expression for InsertQuery
impl Expression for InsertQuery
Source§impl HasOr for InsertQuery
impl HasOr for InsertQuery
Source§impl HasReturning for InsertQuery
impl HasReturning for InsertQuery
Source§fn returning_mut(&mut self) -> &mut Returning
fn returning_mut(&mut self) -> &mut Returning
RETURNING clause to modify.