pub struct InsertQuery {
pub model: &'static ModelSchema,
pub columns: Vec<&'static str>,
pub values: Vec<SqlValue>,
pub returning: Vec<&'static str>,
pub on_conflict: Option<ConflictClause>,
}Expand description
returning names columns the writer should append after RETURNING —
used for Auto<T> PKs, where the row is inserted with the column
omitted so Postgres’ sequence DEFAULT fires, and the assigned value
is then read back into the model.
Fields§
§model: &'static ModelSchema§columns: Vec<&'static str>§values: Vec<SqlValue>§returning: Vec<&'static str>Columns to emit in a RETURNING clause. Empty = no clause; the
executor uses execute(). Non-empty = the executor uses
fetch_one() and the caller reads the returned row.
on_conflict: Option<ConflictClause>Optional ON CONFLICT clause. None = plain INSERT with no
conflict handling (errors on constraint violation).
Implementations§
Source§impl InsertQuery
impl InsertQuery
Sourcepub fn validate(&self) -> Result<(), QueryError>
pub fn validate(&self) -> Result<(), QueryError>
Walk each (column, value) pair and check it against the field’s
declared bounds (max_length, min, max).
§Errors
Returns QueryError::MaxLengthExceeded or QueryError::OutOfRange
for any violating value, or QueryError::UnknownField if a column
in the IR doesn’t correspond to any field in model.
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 moreAuto Trait Implementations§
impl Freeze for InsertQuery
impl RefUnwindSafe for InsertQuery
impl Send for InsertQuery
impl Sync for InsertQuery
impl Unpin for InsertQuery
impl UnsafeUnpin for InsertQuery
impl UnwindSafe for InsertQuery
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more