Skip to main content

Insert

Struct Insert 

Source
pub struct Insert<D, R: InsertRow> { /* private fields */ }

Implementations§

Source§

impl<D, R: InsertRow + Insertable> Insert<D, R>

Source

pub fn values(self, row: R) -> Self

Bulk insert: add another row to the same statement.

Source

pub fn values_all(self, rows: impl IntoIterator<Item = R>) -> Self

The same for a collection. Infallible, unlike the seed’s: this statement already has a row, so an empty collection adds nothing rather than describing an INSERT with nothing in it.

Source§

impl<D: Dialect, R: InsertRow> Insert<D, R>

Source

pub fn on_conflict_do_nothing( self, target: impl ConflictTarget<R::Table>, ) -> Self

ON CONFLICT (..) DO NOTHING.

Source

pub fn on_conflict_do_update( self, target: impl ConflictTarget<R::Table>, set: Assignments<R::Table>, ) -> Self

ON CONFLICT (..) DO UPDATE SET .., taking the same Assignments an UPDATE sets.

Trait Implementations§

Source§

impl<D: Dialect, R: InsertRow> Statement for Insert<D, R>

Source§

type Dialect = D

Source§

type Table = <R as InsertRow>::Table

Source§

fn to_sql(&self, _dialect: Self::Dialect) -> (String, Vec<Value>)

The dialect is an argument for the reason Select::to_sql’s is.
Source§

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.

Auto Trait Implementations§

§

impl<D, R> Freeze for Insert<D, R>
where Option<ConflictClause<<R as InsertRow>::Table>>: Freeze, PhantomData<fn() -> (D, R)>: Freeze,

§

impl<D, R> RefUnwindSafe for Insert<D, R>
where Option<ConflictClause<<R as InsertRow>::Table>>: RefUnwindSafe, PhantomData<fn() -> (D, R)>: RefUnwindSafe,

§

impl<D, R> Send for Insert<D, R>
where Option<ConflictClause<<R as InsertRow>::Table>>: Send, PhantomData<fn() -> (D, R)>: Send,

§

impl<D, R> Sync for Insert<D, R>
where Option<ConflictClause<<R as InsertRow>::Table>>: Sync, PhantomData<fn() -> (D, R)>: Sync,

§

impl<D, R> Unpin for Insert<D, R>
where Option<ConflictClause<<R as InsertRow>::Table>>: Unpin, PhantomData<fn() -> (D, R)>: Unpin,

§

impl<D, R> UnsafeUnpin for Insert<D, R>
where Option<ConflictClause<<R as InsertRow>::Table>>: UnsafeUnpin, PhantomData<fn() -> (D, R)>: UnsafeUnpin,

§

impl<D, R> UnwindSafe for Insert<D, R>
where Option<ConflictClause<<R as InsertRow>::Table>>: UnwindSafe, PhantomData<fn() -> (D, R)>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<S> Superset<Nil, Nil> for S

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WrapNullable<NotNull> for T