pub struct UpdateQuery { /* private fields */ }Expand description
UPDATE query builder
Implementations§
Source§impl UpdateQuery
impl UpdateQuery
Sourcepub fn set(self, column: &str, value: &str) -> Self
pub fn set(self, column: &str, value: &str) -> Self
Add a SET assignment (value should be an already-escaped SQL literal)
Sourcepub fn where_clause(self, condition: &str) -> Self
pub fn where_clause(self, condition: &str) -> Self
Add a WHERE condition
§Security (v0.2.2 fix C-6)
Calls check_where_injection to detect high-risk patterns.
Sourcepub fn where_eq(self, column: &str, value: Value) -> Self
pub fn where_eq(self, column: &str, value: Value) -> Self
Add a column = ? AND condition (P0 fix: parameterized binding)
Sourcepub fn where_like(self, column: &str, pattern: Value) -> Self
pub fn where_like(self, column: &str, pattern: Value) -> Self
Add a column LIKE ? AND condition
Sourcepub fn where_in(self, column: &str, values: Vec<Value>) -> Self
pub fn where_in(self, column: &str, values: Vec<Value>) -> Self
Add a column IN (?, ?, ...) AND condition
Sourcepub fn where_between(self, column: &str, low: Value, high: Value) -> Self
pub fn where_between(self, column: &str, low: Value, high: Value) -> Self
Add a column BETWEEN ? AND ? AND condition
Sourcepub fn where_null(self, column: &str) -> Self
pub fn where_null(self, column: &str) -> Self
Add a column IS NULL AND condition
Sourcepub fn where_not_null(self, column: &str) -> Self
pub fn where_not_null(self, column: &str) -> Self
Add a column IS NOT NULL AND condition
Sourcepub fn returning(self, columns: &[&str]) -> Self
pub fn returning(self, columns: &[&str]) -> Self
Set the RETURNING clause (supported by PostgreSQL/SQLite 3.35+)
Returns the new values of specified columns after UPDATE. MySQL does not support
RETURNING; it is ignored in build() (MySQL style) and under MySQL dialect in
build_with_dialect().
Sourcepub fn returning_all(self) -> Self
pub fn returning_all(self) -> Self
Set RETURNING * (return all columns)
Sourcepub fn build(self) -> String
pub fn build(self) -> String
Generate SQL
§Security (gate 9 fix)
Table and column names are escaped via quote_ident() and wrapped in backticks,
preventing malicious identifiers containing ` from breaking out.
Sourcepub fn build_with_dialect(self, db_type: DbType) -> String
pub fn build_with_dialect(self, db_type: DbType) -> String
Generate SQL for the specified dialect
Sourcepub fn build_with_params(self, db_type: DbType) -> BuiltQuery
pub fn build_with_params(self, db_type: DbType) -> BuiltQuery
Generate parameterized SQL (parameterized query, P0 fix: SQL injection prevention)
WHERE conditions can come from parameterized APIs like where_eq/where_in/where_between,
with user input bound as parameters rather than string concatenation.
Note: SET values are still raw strings; for parameterized SET, use the ORM’s save() interface.
Trait Implementations§
Source§impl Clone for UpdateQuery
impl Clone for UpdateQuery
Source§fn clone(&self) -> UpdateQuery
fn clone(&self) -> UpdateQuery
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 UpdateQuery
impl Debug for UpdateQuery
Source§impl Default for UpdateQuery
impl Default for UpdateQuery
Source§fn default() -> UpdateQuery
fn default() -> UpdateQuery
Auto Trait Implementations§
impl Freeze for UpdateQuery
impl RefUnwindSafe for UpdateQuery
impl Send for UpdateQuery
impl Sync for UpdateQuery
impl Unpin for UpdateQuery
impl UnsafeUnpin for UpdateQuery
impl UnwindSafe for UpdateQuery
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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