Skip to main content

UpdateWrapper

Struct UpdateWrapper 

Source
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 = 42

Fields§

§inner: AbstractWrapper§func: FuncSegments

Implementations§

Source§

impl UpdateWrapper

Source

pub fn new() -> UpdateWrapper

Source

pub fn set( &mut self, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper

SET column = value

设置 SET 字段 = 值

Source

pub fn set_incr_by(&mut self, column: &str, delta: i64) -> &mut UpdateWrapper

SET column = column + delta

SET 字段 = 字段 + 增量

Source

pub fn set_decr_by(&mut self, column: &str, delta: i64) -> &mut UpdateWrapper

SET column = column - delta

SET 字段 = 字段 - 减量

Source

pub fn set_sql(&mut self, sql: &str) -> &mut UpdateWrapper

Append a raw SET fragment (e.g. "age = age + 1", "update_time = now()").

追加原始 SET 片段

Source

pub fn build_set(&self) -> String

Build the SET clause string.

Source

pub fn build_update_sql(&self, table_name: &str) -> String

Build the UPDATE SQL for the given table.

Source

pub fn build_delete_sql(&self, table_name: &str) -> String

Build a DELETE SQL using the WHERE conditions.

Source

pub fn params(&self) -> &[Value]

Return bind parameters.

Source

pub fn sql_set(&self) -> &str

Get the assembled SET SQL fragment (or empty).

Source

pub fn clear(&mut self)

Clear all conditions and SET fragments.

Trait Implementations§

Source§

impl Clone for UpdateWrapper

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Compare for UpdateWrapper

Source§

fn eq(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper

column = value Read more
Source§

fn if_eq( &mut self, condition: bool, column: &str, value: impl Into<Value>, ) -> &mut UpdateWrapper

Conditional eq — only applies when condition is true.
Source§

fn ne(&mut self, column: &str, value: impl Into<Value>) -> &mut UpdateWrapper

column <> value (or IS NULL if value is null) Read more
Source§

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

column > value Read more
Source§

fn 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

column >= value Read more
Source§

fn 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

column < value Read more
Source§

fn 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

column <= value Read more
Source§

fn 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

column BETWEEN val1 AND val2 Read more
Source§

fn 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

column NOT BETWEEN val1 AND val2 Read more
Source§

fn 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

column = value OR column IS NULL (when value is null, just IS NULL) Read more
Source§

impl Debug for UpdateWrapper

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for UpdateWrapper

Source§

fn default() -> UpdateWrapper

Returns the “default value” for a type. Read more
Source§

impl Func for UpdateWrapper

Source§

fn like(&mut self, column: &str, value: &str) -> &mut UpdateWrapper

column LIKE '%value%' Read more
Source§

fn if_like( &mut self, condition: bool, column: &str, value: &str, ) -> &mut UpdateWrapper

Source§

fn not_like(&mut self, column: &str, value: &str) -> &mut UpdateWrapper

column NOT LIKE '%value%' Read more
Source§

fn 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

column LIKE '%value' Read more
Source§

fn 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

column LIKE 'value%' Read more
Source§

fn if_like_right( &mut self, condition: bool, column: &str, value: &str, ) -> &mut UpdateWrapper

Source§

fn is_null(&mut self, column: &str) -> &mut UpdateWrapper

column IS NULL Read more
Source§

fn if_is_null(&mut self, condition: bool, column: &str) -> &mut UpdateWrapper

Source§

fn is_not_null(&mut self, column: &str) -> &mut UpdateWrapper

column IS NOT NULL Read more
Source§

fn 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

column IN (v1, v2, ...) Read more
Source§

fn 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

column NOT IN (v1, v2, ...) Read more
Source§

fn 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

column IN (subquery_sql) Read more
Source§

fn not_in_sql(&mut self, column: &str, sql: &str) -> &mut UpdateWrapper

column NOT IN (subquery_sql) Read more
Source§

fn group_by(&mut self, columns: &[&str]) -> &mut UpdateWrapper

GROUP BY col1, col2, ... Read more
Source§

fn order_by(&mut self, column: &str, is_asc: bool) -> &mut UpdateWrapper

ORDER BY col ASC/DESC Read more
Source§

fn order_by_asc(&mut self, column: &str) -> &mut UpdateWrapper

Source§

fn order_by_desc(&mut self, column: &str) -> &mut UpdateWrapper

Source§

fn having(&mut self, sql: &str) -> &mut UpdateWrapper

HAVING sqlFragment Read more
Source§

impl Join for UpdateWrapper

Source§

fn apply(&mut self, sql: &str) -> &mut UpdateWrapper

追加原生 SQL WHERE 片段(防注入需调用方自行保证)。 Read more
Source§

fn exists(&mut self, sql: &str) -> &mut UpdateWrapper

EXISTS 子查询。 Read more
Source§

fn not_exists(&mut self, sql: &str) -> &mut UpdateWrapper

NOT EXISTS 子查询。 Read more
Source§

fn last(&mut self, sql: &str) -> &mut UpdateWrapper

SQL 末尾追加片段(如 LIMIT 1、FOR UPDATE 等)。 Read more
Source§

fn comment(&mut self, sql: &str) -> &mut UpdateWrapper

添加 SQL 注释(/* ... */)。 Read more
Source§

fn first(&mut self, sql: &str) -> &mut UpdateWrapper

SQL 首部插入片段(如 hint)。 Read more
Source§

impl Nested for UpdateWrapper

Source§

fn or(&mut self) -> &mut UpdateWrapper

Bare OR connector — changes the next condition’s connector to OR. Read more
Source§

fn and_group(&mut self, inner_sql: &str) -> &mut UpdateWrapper

AND (...) — adds a grouped AND block. Read more
Source§

fn or_group(&mut self, inner_sql: &str) -> &mut UpdateWrapper

OR (...) — adds a grouped OR block. Read more
Source§

fn nested(&mut self, inner_sql: &str) -> &mut UpdateWrapper

(inner_sql) — nested without explicit AND/OR (uses current connector). Read more
Source§

fn not_group(&mut self, inner_sql: &str) -> &mut UpdateWrapper

NOT (...) — negation group. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.