pub struct InsertSelectStmt {
pub table: TableName,
pub columns: Vec<ColumnName>,
pub select_exprs: Vec<Expr>,
pub unnest: Unnest,
pub on_conflict: Option<OnConflict>,
pub returning: Vec<ColumnName>,
}Expand description
An INSERT … SELECT statement for bulk inserts.
Used with UNNEST for efficient bulk operations:
INSERT INTO products (handle, status, created_at)
SELECT handle, status, NOW()
FROM UNNEST($1::text[], $2::text[]) AS t(handle, status)
RETURNING id, handle, statusFields§
§table: TableNameThe table to insert into.
columns: Vec<ColumnName>Column names for the insert.
select_exprs: Vec<Expr>Expressions to select (parallel to columns).
unnest: UnnestThe UNNEST source.
on_conflict: Option<OnConflict>Optional ON CONFLICT clause for upsert behavior.
returning: Vec<ColumnName>Columns to return after insert (RETURNING clause).
Implementations§
Source§impl InsertSelectStmt
impl InsertSelectStmt
pub fn new(table: TableName, unnest: Unnest) -> Self
Sourcepub fn column(self, name: ColumnName, expr: Expr) -> Self
pub fn column(self, name: ColumnName, expr: Expr) -> Self
Add a column with its select expression.
pub fn on_conflict(self, conflict: OnConflict) -> Self
pub fn returning(self, cols: impl IntoIterator<Item = ColumnName>) -> Self
Trait Implementations§
Source§impl Clone for InsertSelectStmt
impl Clone for InsertSelectStmt
Source§fn clone(&self) -> InsertSelectStmt
fn clone(&self) -> InsertSelectStmt
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InsertSelectStmt
impl Debug for InsertSelectStmt
Source§impl Render for InsertSelectStmt
impl Render for InsertSelectStmt
Auto Trait Implementations§
impl Freeze for InsertSelectStmt
impl RefUnwindSafe for InsertSelectStmt
impl Send for InsertSelectStmt
impl Sync for InsertSelectStmt
impl Unpin for InsertSelectStmt
impl UnsafeUnpin for InsertSelectStmt
impl UnwindSafe for InsertSelectStmt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more