pub struct UpdateQuery { /* private fields */ }Expand description
UPDATE 查询构造器
Implementations§
Source§impl UpdateQuery
impl UpdateQuery
Sourcepub fn new() -> UpdateQuery
pub fn new() -> UpdateQuery
创建空的 UPDATE 查询
Sourcepub fn table(self, table: &str) -> UpdateQuery
pub fn table(self, table: &str) -> UpdateQuery
设置目标表
Sourcepub fn set(self, column: &str, value: &str) -> UpdateQuery
pub fn set(self, column: &str, value: &str) -> UpdateQuery
添加 SET 赋值(值应为已转义的 SQL 字面量)
Sourcepub fn sets(self, pairs: &[(&str, &str)]) -> UpdateQuery
pub fn sets(self, pairs: &[(&str, &str)]) -> UpdateQuery
批量添加 SET 赋值
Sourcepub fn where_clause(self, condition: &str) -> UpdateQuery
pub fn where_clause(self, condition: &str) -> UpdateQuery
Sourcepub fn where_eq(self, column: &str, value: Value) -> UpdateQuery
pub fn where_eq(self, column: &str, value: Value) -> UpdateQuery
添加 column = ? AND 条件(P0 修复:参数化绑定)
Sourcepub fn where_ne(self, column: &str, value: Value) -> UpdateQuery
pub fn where_ne(self, column: &str, value: Value) -> UpdateQuery
添加 column <> ? AND 条件
Sourcepub fn where_gt(self, column: &str, value: Value) -> UpdateQuery
pub fn where_gt(self, column: &str, value: Value) -> UpdateQuery
添加 column > ? AND 条件
Sourcepub fn where_ge(self, column: &str, value: Value) -> UpdateQuery
pub fn where_ge(self, column: &str, value: Value) -> UpdateQuery
添加 column >= ? AND 条件
Sourcepub fn where_lt(self, column: &str, value: Value) -> UpdateQuery
pub fn where_lt(self, column: &str, value: Value) -> UpdateQuery
添加 column < ? AND 条件
Sourcepub fn where_le(self, column: &str, value: Value) -> UpdateQuery
pub fn where_le(self, column: &str, value: Value) -> UpdateQuery
添加 column <= ? AND 条件
Sourcepub fn where_like(self, column: &str, pattern: Value) -> UpdateQuery
pub fn where_like(self, column: &str, pattern: Value) -> UpdateQuery
添加 column LIKE ? AND 条件
Sourcepub fn where_in(self, column: &str, values: Vec<Value>) -> UpdateQuery
pub fn where_in(self, column: &str, values: Vec<Value>) -> UpdateQuery
添加 column IN (?, ?, ...) AND 条件
Sourcepub fn where_between(self, column: &str, low: Value, high: Value) -> UpdateQuery
pub fn where_between(self, column: &str, low: Value, high: Value) -> UpdateQuery
添加 column BETWEEN ? AND ? AND 条件
Sourcepub fn where_null(self, column: &str) -> UpdateQuery
pub fn where_null(self, column: &str) -> UpdateQuery
添加 column IS NULL AND 条件
Sourcepub fn where_not_null(self, column: &str) -> UpdateQuery
pub fn where_not_null(self, column: &str) -> UpdateQuery
添加 column IS NOT NULL AND 条件
Sourcepub fn returning(self, columns: &[&str]) -> UpdateQuery
pub fn returning(self, columns: &[&str]) -> UpdateQuery
设置 RETURNING 子句(PostgreSQL/SQLite 3.35+ 支持)
在 UPDATE 后返回指定列的新值。MySQL 不支持 RETURNING,
在 build()(MySQL 风格)和 build_with_dialect() 的 MySQL 方言下被忽略。
Sourcepub fn returning_all(self) -> UpdateQuery
pub fn returning_all(self) -> UpdateQuery
设置 RETURNING *(返回所有列)
Sourcepub fn build_with_dialect(self, db_type: DbType) -> String
pub fn build_with_dialect(self, db_type: DbType) -> String
按指定方言生成 SQL
Sourcepub fn build_with_params(self, db_type: DbType) -> BuiltQuery
pub fn build_with_params(self, db_type: DbType) -> BuiltQuery
生成带参数的 SQL(参数化查询,P0 修复:SQL 注入防护)
WHERE 条件可来自 where_eq/where_in/where_between 等参数化 API,
用户输入作为参数绑定,而非字符串拼接。
注意:SET 值仍为原始字符串,如需参数化 SET 请使用 ORM 的 save() 接口。
Trait Implementations§
Source§impl Clone for UpdateQuery
impl Clone for UpdateQuery
Source§fn clone(&self) -> UpdateQuery
fn clone(&self) -> UpdateQuery
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 UpdateQuery
impl Debug for UpdateQuery
Source§impl Default for UpdateQuery
impl Default for UpdateQuery
Source§fn default() -> UpdateQuery
fn default() -> UpdateQuery
Returns the “default value” for a type. Read more
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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