pub struct UpdateWrapper {
pub inner: AbstractWrapper,
pub func: FuncSegments,
/* private fields */
}Expand description
Update wrapper with String column names.
Mirrors Java com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper<T>.
§Example
ⓘ
use rbatis_plus::core::conditions::update::UpdateWrapper;
let w = UpdateWrapper::new()
.set("name", "Bob")
.set_sql("age = age + 1")
.eq("id", 42);
let sql = w.build_update_sql("sys_user");
// UPDATE sys_user SET name = 'Bob', age = age + 1 WHERE id = 42Fields§
§inner: AbstractWrapper§func: FuncSegmentsImplementations§
Source§impl UpdateWrapper
impl UpdateWrapper
pub fn new() -> UpdateWrapper
Sourcepub fn set(
&mut self,
column: &str,
value: impl Into<Value>,
) -> &mut UpdateWrapper
pub fn set( &mut self, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper
SET column = value
设置 SET 字段 = 值
Sourcepub fn set_incr_by(&mut self, column: &str, delta: i64) -> &mut UpdateWrapper
pub fn set_incr_by(&mut self, column: &str, delta: i64) -> &mut UpdateWrapper
SET column = column + delta
SET 字段 = 字段 + 增量
Sourcepub fn set_decr_by(&mut self, column: &str, delta: i64) -> &mut UpdateWrapper
pub fn set_decr_by(&mut self, column: &str, delta: i64) -> &mut UpdateWrapper
SET column = column - delta
SET 字段 = 字段 - 减量
Sourcepub fn set_sql(&mut self, sql: &str) -> &mut UpdateWrapper
pub fn set_sql(&mut self, sql: &str) -> &mut UpdateWrapper
Append a raw SET fragment (e.g. "age = age + 1", "update_time = now()").
追加原始 SET 片段
Sourcepub fn build_update_sql(&self, table_name: &str) -> String
pub fn build_update_sql(&self, table_name: &str) -> String
Build the UPDATE SQL for the given table.
Sourcepub fn build_delete_sql(&self, table_name: &str) -> String
pub fn build_delete_sql(&self, table_name: &str) -> String
Build a DELETE SQL using the WHERE conditions.
Trait Implementations§
Source§impl Clone for UpdateWrapper
impl Clone for UpdateWrapper
Source§fn clone(&self) -> UpdateWrapper
fn clone(&self) -> UpdateWrapper
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 Compare for UpdateWrapper
impl Compare for UpdateWrapper
Source§fn eq(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
fn eq(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
column = value Read moreSource§fn if_eq(
&mut self,
condition: bool,
column: &str,
value: impl Into<Value>,
) -> &mut UpdateWrapper
fn if_eq( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper
Conditional eq — only applies when
condition is true.fn if_ne( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper
Source§fn gt(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
fn gt(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
column > value Read morefn if_gt( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper
Source§fn ge(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
fn ge(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
column >= value Read morefn if_ge( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper
Source§fn lt(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
fn lt(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
column < value Read morefn if_lt( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper
Source§fn le(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
fn le(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper
column <= value Read morefn if_le( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper
Source§fn between(
&mut self,
column: &str,
val1: impl Into<Value>,
val2: impl Into<Value>,
) -> &mut UpdateWrapper
fn between( &mut self, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut UpdateWrapper
column BETWEEN val1 AND val2 Read morefn if_between( &mut self, condition: bool, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut UpdateWrapper
Source§fn not_between(
&mut self,
column: &str,
val1: impl Into<Value>,
val2: impl Into<Value>,
) -> &mut UpdateWrapper
fn not_between( &mut self, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut UpdateWrapper
column NOT BETWEEN val1 AND val2 Read morefn if_not_between( &mut self, condition: bool, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut UpdateWrapper
Source§fn eq_or_is_null(
&mut self,
column: &str,
value: impl Into<Value>,
) -> &mut UpdateWrapper
fn eq_or_is_null( &mut self, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper
column = value OR column IS NULL (when value is null, just IS NULL) Read moreSource§impl Debug for UpdateWrapper
impl Debug for UpdateWrapper
Source§impl Default for UpdateWrapper
impl Default for UpdateWrapper
Source§fn default() -> UpdateWrapper
fn default() -> UpdateWrapper
Returns the “default value” for a type. Read more
Source§impl Func for UpdateWrapper
impl Func for UpdateWrapper
Source§fn like(&mut self, column: &str, value: &str) -> &mut UpdateWrapper
fn like(&mut self, column: &str, value: &str) -> &mut UpdateWrapper
column LIKE '%value%' Read morefn if_like( &mut self, condition: bool, column: &str, value: &str, ) -> &mut UpdateWrapper
Source§fn not_like(&mut self, column: &str, value: &str) -> &mut UpdateWrapper
fn not_like(&mut self, column: &str, value: &str) -> &mut UpdateWrapper
column NOT LIKE '%value%' Read morefn if_not_like( &mut self, condition: bool, column: &str, value: &str, ) -> &mut UpdateWrapper
Source§fn like_left(&mut self, column: &str, value: &str) -> &mut UpdateWrapper
fn like_left(&mut self, column: &str, value: &str) -> &mut UpdateWrapper
column LIKE '%value' Read morefn if_like_left( &mut self, condition: bool, column: &str, value: &str, ) -> &mut UpdateWrapper
Source§fn like_right(&mut self, column: &str, value: &str) -> &mut UpdateWrapper
fn like_right(&mut self, column: &str, value: &str) -> &mut UpdateWrapper
column LIKE 'value%' Read morefn if_like_right( &mut self, condition: bool, column: &str, value: &str, ) -> &mut UpdateWrapper
fn if_is_null(&mut self, condition: bool, column: &str) -> &mut UpdateWrapper
Source§fn is_not_null(&mut self, column: &str) -> &mut UpdateWrapper
fn is_not_null(&mut self, column: &str) -> &mut UpdateWrapper
column IS NOT NULL Read morefn if_is_not_null( &mut self, condition: bool, column: &str, ) -> &mut UpdateWrapper
Source§fn in_values(&mut self, column: &str, values: Vec<Value>) -> &mut UpdateWrapper
fn in_values(&mut self, column: &str, values: Vec<Value>) -> &mut UpdateWrapper
column IN (v1, v2, ...) Read morefn if_in_values( &mut self, condition: bool, column: &str, values: Vec<Value>, ) -> &mut UpdateWrapper
Source§fn not_in(&mut self, column: &str, values: Vec<Value>) -> &mut UpdateWrapper
fn not_in(&mut self, column: &str, values: Vec<Value>) -> &mut UpdateWrapper
column NOT IN (v1, v2, ...) Read morefn if_not_in( &mut self, condition: bool, column: &str, values: Vec<Value>, ) -> &mut UpdateWrapper
Source§fn in_sql(&mut self, column: &str, sql: &str) -> &mut UpdateWrapper
fn in_sql(&mut self, column: &str, sql: &str) -> &mut UpdateWrapper
column IN (subquery_sql) Read moreSource§fn not_in_sql(&mut self, column: &str, sql: &str) -> &mut UpdateWrapper
fn not_in_sql(&mut self, column: &str, sql: &str) -> &mut UpdateWrapper
column NOT IN (subquery_sql) Read moreSource§fn group_by(&mut self, columns: &[&str]) -> &mut UpdateWrapper
fn group_by(&mut self, columns: &[&str]) -> &mut UpdateWrapper
GROUP BY col1, col2, ... Read moreSource§fn order_by(&mut self, column: &str, is_asc: bool) -> &mut UpdateWrapper
fn order_by(&mut self, column: &str, is_asc: bool) -> &mut UpdateWrapper
ORDER BY col ASC/DESC Read morefn order_by_asc(&mut self, column: &str) -> &mut UpdateWrapper
fn order_by_desc(&mut self, column: &str) -> &mut UpdateWrapper
Source§impl Join for UpdateWrapper
impl Join for UpdateWrapper
Source§fn apply(&mut self, sql: &str) -> &mut UpdateWrapper
fn apply(&mut self, sql: &str) -> &mut UpdateWrapper
追加原生 SQL WHERE 片段(防注入需调用方自行保证)。 Read more
Source§fn not_exists(&mut self, sql: &str) -> &mut UpdateWrapper
fn not_exists(&mut self, sql: &str) -> &mut UpdateWrapper
NOT EXISTS 子查询。 Read more
Source§fn last(&mut self, sql: &str) -> &mut UpdateWrapper
fn last(&mut self, sql: &str) -> &mut UpdateWrapper
Source§impl Nested for UpdateWrapper
impl Nested for UpdateWrapper
Source§fn or(&mut self) -> &mut UpdateWrapper
fn or(&mut self) -> &mut UpdateWrapper
Bare
OR connector — changes the next condition’s connector to OR. Read moreSource§fn and_group(&mut self, inner_sql: &str) -> &mut UpdateWrapper
fn and_group(&mut self, inner_sql: &str) -> &mut UpdateWrapper
AND (...) — adds a grouped AND block. Read moreSource§fn or_group(&mut self, inner_sql: &str) -> &mut UpdateWrapper
fn or_group(&mut self, inner_sql: &str) -> &mut UpdateWrapper
OR (...) — adds a grouped OR block. Read moreAuto Trait Implementations§
impl Freeze for UpdateWrapper
impl RefUnwindSafe for UpdateWrapper
impl Send for UpdateWrapper
impl Sync for UpdateWrapper
impl Unpin for UpdateWrapper
impl UnsafeUnpin for UpdateWrapper
impl UnwindSafe for UpdateWrapper
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