Skip to main content

QueryWrapper

Struct QueryWrapper 

Source
pub struct QueryWrapper {
    pub inner: AbstractWrapper,
    pub func: FuncSegments,
    /* private fields */
}
Expand description

Query wrapper with String column names.

Mirrors Java com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<T>.

§Example

ⓘ
use rbatis_plus::core::conditions::query::QueryWrapper;

let w = QueryWrapper::new()
    .eq("name", "Alice")
    .ge("age", 18)
    .like("email", "gmail")
    .order_by_desc("create_time");

let sql = w.build_select_sql("sys_user");
// SELECT * FROM sys_user WHERE name = 'Alice' AND age >= 18 AND email LIKE '%gmail%' ORDER BY create_time DESC

Fields§

§inner: AbstractWrapper§func: FuncSegments

Implementations§

Source§

impl QueryWrapper

Source

pub fn new() -> QueryWrapper

Source

pub fn select(&mut self, columns: &[&str]) -> &mut QueryWrapper

Set the SELECT columns. Overwrites previous selection.

设置查询字段

Source

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

Build the SELECT SQL for the given table.

Source

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

Build a COUNT SQL for the given table (for pagination).

Source

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

Return bind parameters.

Source

pub fn clear(&mut self)

Clear all conditions.

Source§

impl QueryWrapper

Legacy compatibility entry point — absorbs the rbatis-wrapper crate API.

In new code prefer QueryWrapper directly; this module provides the same query(), get_one(), delete(), and page() async methods that rbatis-wrapper exposed, now backed by the full QueryWrapper.

Source

pub async fn query<T>( &self, rb: &(dyn Executor + 'static), table_name: &str, ) -> Result<Vec<T>, Error>

Execute the query and return a list of entities.

执行查询返回列表

Source

pub async fn get_one<T>( &self, rb: &(dyn Executor + 'static), table_name: &str, ) -> Result<Option<T>, Error>

Execute the query and return a single entity (or None).

执行查询返回单条

Source

pub async fn page<T>( &self, rb: &(dyn Executor + 'static), table_name: &str, page_no: u64, page_size: u64, ) -> Result<Page<T>, Error>

Execute a paginated query.

执行分页查询

Trait Implementations§

Source§

impl Clone for QueryWrapper

Source§

fn clone(&self) -> QueryWrapper

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 QueryWrapper

Source§

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

column = value Read more
Source§

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

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

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

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 QueryWrapper

Source§

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

column > value Read more
Source§

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

Source§

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

column >= value Read more
Source§

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

Source§

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

column < value Read more
Source§

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

Source§

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

column <= value Read more
Source§

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

Source§

fn between( &mut self, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut QueryWrapper

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 QueryWrapper

Source§

fn not_between( &mut self, column: &str, val1: impl Into<Value>, val2: impl Into<Value>, ) -> &mut QueryWrapper

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 QueryWrapper

Source§

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

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

impl Debug for QueryWrapper

Source§

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

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

impl Default for QueryWrapper

Source§

fn default() -> QueryWrapper

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

impl Func for QueryWrapper

Source§

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

column LIKE '%value%' Read more
Source§

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

Source§

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

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

fn if_not_like( &mut self, condition: bool, column: &str, value: &str, ) -> &mut QueryWrapper

Source§

fn like_left(&mut self, column: &str, value: &str) -> &mut QueryWrapper

column LIKE '%value' Read more
Source§

fn if_like_left( &mut self, condition: bool, column: &str, value: &str, ) -> &mut QueryWrapper

Source§

fn like_right(&mut self, column: &str, value: &str) -> &mut QueryWrapper

column LIKE 'value%' Read more
Source§

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

Source§

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

column IS NULL Read more
Source§

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

Source§

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

column IS NOT NULL Read more
Source§

fn if_is_not_null(&mut self, condition: bool, column: &str) -> &mut QueryWrapper

Source§

fn in_values(&mut self, column: &str, values: Vec<Value>) -> &mut QueryWrapper

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

fn if_in_values( &mut self, condition: bool, column: &str, values: Vec<Value>, ) -> &mut QueryWrapper

Source§

fn not_in(&mut self, column: &str, values: Vec<Value>) -> &mut QueryWrapper

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

fn if_not_in( &mut self, condition: bool, column: &str, values: Vec<Value>, ) -> &mut QueryWrapper

Source§

fn in_sql(&mut self, column: &str, sql: &str) -> &mut QueryWrapper

column IN (subquery_sql) Read more
Source§

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

column NOT IN (subquery_sql) Read more
Source§

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

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

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

ORDER BY col ASC/DESC Read more
Source§

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

Source§

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

Source§

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

HAVING sqlFragment Read more
Source§

impl Join for QueryWrapper

Source§

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

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

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

EXISTS 子查询。 Read more
Source§

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

NOT EXISTS 子查询。 Read more
Source§

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

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

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

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

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

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

impl Nested for QueryWrapper

Source§

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

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

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

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

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

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

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

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

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

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.