Expr

Struct Expr 

Source
pub struct Expr { /* private fields */ }
Expand description

A SQL expression (for WHERE, HAVING, etc.).

Implementations§

Source§

impl Expr

Source

pub fn from_fragment(fragment: SqlFragment) -> Self

Create an expression from a SQL fragment.

Source

pub fn column(name: &str) -> Self

Create a column reference expression.

Source

pub fn qualified_column(table: &str, column: &str) -> Self

Create a qualified column reference (table.column).

Source

pub fn eq(column: &str, value: impl Into<SqlParam>) -> Self

Create an equality expression: column = $1

Source

pub fn neq(column: &str, value: impl Into<SqlParam>) -> Self

Create a not-equal expression: column <> $1

Source

pub fn gt(column: &str, value: impl Into<SqlParam>) -> Self

Create a greater-than expression: column > $1

Source

pub fn gte(column: &str, value: impl Into<SqlParam>) -> Self

Create a greater-than-or-equal expression: column >= $1

Source

pub fn lt(column: &str, value: impl Into<SqlParam>) -> Self

Create a less-than expression: column < $1

Source

pub fn lte(column: &str, value: impl Into<SqlParam>) -> Self

Create a less-than-or-equal expression: column <= $1

Source

pub fn like(column: &str, pattern: impl Into<SqlParam>) -> Self

Create a LIKE expression: column LIKE $1

Source

pub fn ilike(column: &str, pattern: impl Into<SqlParam>) -> Self

Create an ILIKE expression: column ILIKE $1

Source

pub fn is_null(column: &str) -> Self

Create an IS NULL expression: column IS NULL

Source

pub fn is_not_null(column: &str) -> Self

Create an IS NOT NULL expression: column IS NOT NULL

Source

pub fn in_list(column: &str, values: Vec<SqlParam>) -> Self

Create an IN expression: column IN ($1, $2, …)

Source

pub fn contains(column: &str, value: impl Into<SqlParam>) -> Self

Create a contains expression: column @> $1

Source

pub fn contained_by(column: &str, value: impl Into<SqlParam>) -> Self

Create a contained-by expression: column <@ $1

Source

pub fn overlaps(column: &str, value: impl Into<SqlParam>) -> Self

Create an overlap expression: column && $1

Source

pub fn fts( column: &str, query: impl Into<SqlParam>, language: Option<&str>, ) -> Self

Create a full-text search expression: column @@ to_tsquery($1)

Source

pub fn not(self) -> Self

Negate this expression: NOT (expr)

Source

pub fn and(self, other: Expr) -> Self

Combine with AND: self AND other

Source

pub fn or(self, other: Expr) -> Self

Combine with OR: self OR other

Source

pub fn and_all(exprs: impl IntoIterator<Item = Expr>) -> Self

Combine multiple expressions with AND.

Source

pub fn or_all(exprs: impl IntoIterator<Item = Expr>) -> Self

Combine multiple expressions with OR.

Source

pub fn into_fragment(self) -> SqlFragment

Convert to a SQL fragment.

Source

pub fn sql(&self) -> &str

Get the SQL string.

Source

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

Get the parameters.

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Expr

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnwindSafe for Expr

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.