pub struct UpdateQuery { /* private fields */ }Expand description
UPDATE 查询构造器
Implementations§
Source§impl UpdateQuery
impl UpdateQuery
Sourcepub fn where_clause(self, condition: &str) -> Self
pub fn where_clause(self, condition: &str) -> Self
Sourcepub fn where_like(self, column: &str, pattern: Value) -> Self
pub fn where_like(self, column: &str, pattern: Value) -> Self
添加 column LIKE ? AND 条件
Sourcepub fn where_in(self, column: &str, values: Vec<Value>) -> Self
pub fn where_in(self, column: &str, values: Vec<Value>) -> Self
添加 column IN (?, ?, ...) AND 条件
Sourcepub fn where_between(self, column: &str, low: Value, high: Value) -> Self
pub fn where_between(self, column: &str, low: Value, high: Value) -> Self
添加 column BETWEEN ? AND ? AND 条件
Sourcepub fn where_null(self, column: &str) -> Self
pub fn where_null(self, column: &str) -> Self
添加 column IS NULL AND 条件
Sourcepub fn where_not_null(self, column: &str) -> Self
pub fn where_not_null(self, column: &str) -> Self
添加 column IS NOT NULL AND 条件
Sourcepub fn returning(self, columns: &[&str]) -> Self
pub fn returning(self, columns: &[&str]) -> Self
设置 RETURNING 子句(PostgreSQL/SQLite 3.35+ 支持)
在 UPDATE 后返回指定列的新值。MySQL 不支持 RETURNING,
在 build()(MySQL 风格)和 build_with_dialect() 的 MySQL 方言下被忽略。
Sourcepub fn returning_all(self) -> Self
pub fn returning_all(self) -> Self
设置 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