Expr

Enum Expr 

Source
#[non_exhaustive]
pub enum Expr {
Show 15 variants Column(ColumnRef), Tuple(Vec<Expr>), Unary(UnOper, Box<Expr>), FunctionCall(FunctionCall), Binary(Box<Expr>, BinOper, Box<Expr>), SubQuery(Option<SubQueryOper>, Box<SubQueryStatement>), Value(Value), Values(Vec<Value>), Custom(Cow<'static, str>), CustomWithExpr(Cow<'static, str>, Vec<Expr>), Keyword(Keyword), AsEnum(DynIden, Box<Expr>), Case(Box<CaseStatement>), Constant(Value), TypeName(TypeRef),
}
Expand description

An arbitrary, dynamically-typed SQL expression.

It can be used in select fields, where clauses and many other places.

More concreterly, under the hood Exprs can be:

  • Rust values
  • SQL identifiers
  • SQL function calls
  • various operators and sub-queries

If something is not supported here, look into BinOper::Custom, Func::cust, or Expr::cust* as a workaround, and consider reporting your issue.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Column(ColumnRef)

§

Tuple(Vec<Expr>)

§

Unary(UnOper, Box<Expr>)

§

FunctionCall(FunctionCall)

§

Binary(Box<Expr>, BinOper, Box<Expr>)

§

SubQuery(Option<SubQueryOper>, Box<SubQueryStatement>)

§

Value(Value)

§

Values(Vec<Value>)

§

Custom(Cow<'static, str>)

§

CustomWithExpr(Cow<'static, str>, Vec<Expr>)

§

Keyword(Keyword)

§

AsEnum(DynIden, Box<Expr>)

§

Case(Box<CaseStatement>)

§

Constant(Value)

§

TypeName(TypeRef)

Implementations§

Source§

impl Expr

Source

pub fn asterisk() -> Expr

👎Deprecated since 0.29.0: Please use the [Asterisk]
Source

pub fn col<T>(n: T) -> Expr
where T: IntoColumnRef,

Express the target column without table prefix.

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::col(Char::SizeW).eq(1))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `size_w` = 1"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" = 1"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" = 1"#
);
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::col((Char::Table, Char::SizeW)).eq(1))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` = 1"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" = 1"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" = 1"#
);
Source

pub fn column<T>(n: T) -> Expr
where T: IntoColumnRef,

Express the target column without table prefix, returning a Expr.

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::column(Char::SizeW).eq(1))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `size_w` = 1"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" = 1"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" = 1"#
);
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::column((Char::Table, Char::SizeW)).eq(1))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` = 1"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" = 1"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" = 1"#
);
Source

pub fn tuple<I>(n: I) -> Expr
where I: IntoIterator<Item = Expr>,

Wraps tuple of Expr, can be used for tuple comparison

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(
        Expr::tuple([Expr::col(Char::SizeW).into(), Expr::value(100)])
            .lt(Expr::tuple([Expr::value(500), Expr::value(100)])))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE (`size_w`, 100) < (500, 100)"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE ("size_w", 100) < (500, 100)"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE ("size_w", 100) < (500, 100)"#
);
Source

pub fn table_asterisk<T>(t: T) -> Expr
where T: IntoIden,

👎Deprecated since 0.29.0: Please use the [Asterisk]
Source

pub fn val<V>(v: V) -> Expr
where V: Into<Value>,

Express a Value, returning a Expr.

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::val(1).into())
    .and_where(Expr::val(2.5).into())
    .and_where(Expr::val("3").into())
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 AND 2.5 AND '3'"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 AND 2.5 AND '3'"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 AND 2.5 AND '3'"#
);
Source

pub fn expr<T>(expr: T) -> Expr
where T: Into<Expr>,

Wrap an expression to perform some operation on it later.

Since sea_query 0.32.0 (sea_orm 1.1.1), this is not necessary in most cases!

Some SQL operations used to be defined only as inherent methods on Expr. Thus, to use them, you needed to manually convert from other types to Expr. But now these operations are also defined as ExprTrait methods that can be called directly on any expression type,

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    // This is the old style, when `Expr::expr` was necessary:
    .and_where(Expr::expr(Expr::col(Char::SizeW).if_null(0)).gt(2))
    .to_owned();

// But since 0.32.0, this compiles too:
let _ = Expr::col(Char::SizeW).if_null(0).gt(2);

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE IFNULL(`size_w`, 0) > 2"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE COALESCE("size_w", 0) > 2"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE IFNULL("size_w", 0) > 2"#
);
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .column(Char::Character)
    .from(Char::Table)
    // This is the old style, when `Expr::expr` was necessary:
    .and_where(Expr::expr(Func::lower(Expr::col(Char::Character))).is_in(["a", "b"]))
    .to_owned();

// But since 0.32.0, this compiles too:
let _ = Func::lower(Expr::col(Char::Character)).is_in(["a", "b"]);

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character` FROM `character` WHERE LOWER(`character`) IN ('a', 'b')"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character" FROM "character" WHERE LOWER("character") IN ('a', 'b')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character" FROM "character" WHERE LOWER("character") IN ('a', 'b')"#
);
Source

pub fn value<V>(v: V) -> Expr
where V: Into<Expr>,

Express a Value, returning a Expr.

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::value(1))
    .and_where(Expr::value(2.5))
    .and_where(Expr::value("3"))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 AND 2.5 AND '3'"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 AND 2.5 AND '3'"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 AND 2.5 AND '3'"#
);
Source

pub fn cust<T>(s: T) -> Expr
where T: Into<Cow<'static, str>>,

Express any custom expression in &str.

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::cust("1 = 1"))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 = 1"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 = 1"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 = 1"#
);
Source

pub fn cust_with_values<T, V, I>(s: T, v: I) -> Expr
where T: Into<Cow<'static, str>>, V: Into<Value>, I: IntoIterator<Item = V>,

Express any custom expression with Value. Use this if your expression needs variables.

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::col(Char::Id).eq(1))
    .and_where(Expr::cust_with_values("6 = ? * ?", [2, 3]))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `id` = 1 AND (6 = 2 * 3)"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "id" = 1 AND (6 = 2 * 3)"#
);
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::col(Char::Id).eq(1))
    .and_where(Expr::cust_with_values("6 = $2 * $1", [3, 2]))
    .to_owned();

assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "id" = 1 AND (6 = 2 * 3)"#
);
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .expr(Expr::cust_with_values("6 = ? * ?", [2, 3]))
    .to_owned();

assert_eq!(query.to_string(MysqlQueryBuilder), r#"SELECT 6 = 2 * 3"#);
assert_eq!(query.to_string(SqliteQueryBuilder), r#"SELECT 6 = 2 * 3"#);

Postgres only: use $$ to escape $

use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .expr(Expr::cust_with_values("$1 $$ $2", ["a", "b"]))
    .to_owned();

assert_eq!(query.to_string(PostgresQueryBuilder), r#"SELECT 'a' $ 'b'"#);
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .expr(Expr::cust_with_values("data @? ($1::JSONPATH)", ["hello"]))
    .to_owned();

assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT data @? ('hello'::JSONPATH)"#
);
Source

pub fn cust_with_expr<T, E>(s: T, expr: E) -> Expr
where T: Into<Cow<'static, str>>, E: Into<Expr>,

Express any custom expression with Expr. Use this if your expression needs other expression.

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .expr(Expr::val(1).add(2))
    .expr(Expr::cust_with_expr("data @? ($1::JSONPATH)", "hello"))
    .to_owned();
let (sql, values) = query.build(PostgresQueryBuilder);

assert_eq!(sql, r#"SELECT $1 + $2, data @? ($3::JSONPATH)"#);
assert_eq!(
    values,
    Values(vec![1i32.into(), 2i32.into(), "hello".into()])
);
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .expr(Expr::cust_with_expr(
        "json_agg(DISTINCT $1)",
        Expr::col(Char::Character),
    ))
    .to_owned();

assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT json_agg(DISTINCT "character")"#
);
Source

pub fn cust_with_exprs<T, I>(s: T, v: I) -> Expr
where T: Into<Cow<'static, str>>, I: IntoIterator<Item = Expr>,

Express any custom expression with Expr. Use this if your expression needs other expressions.

Source

pub fn exists(sel: SelectStatement) -> Expr

Express a EXISTS sub-query expression.

§Examples
use sea_query::{*, tests_cfg::*};

let query = Query::select()
    .expr_as(Expr::exists(Query::select().column(Char::Id).from(Char::Table).take()), "character_exists")
    .expr_as(Expr::exists(Query::select().column(Glyph::Id).from(Glyph::Table).take()), "glyph_exists")
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT EXISTS(SELECT `id` FROM `character`) AS `character_exists`, EXISTS(SELECT `id` FROM `glyph`) AS `glyph_exists`"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT EXISTS(SELECT "id" FROM "character") AS "character_exists", EXISTS(SELECT "id" FROM "glyph") AS "glyph_exists""#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT EXISTS(SELECT "id" FROM "character") AS "character_exists", EXISTS(SELECT "id" FROM "glyph") AS "glyph_exists""#
);
Source

pub fn not_exists(sel: SelectStatement) -> Expr

Express a NOT EXISTS sub-query expression.

use sea_query::{*, tests_cfg::*};

let query = Query::select()
    .expr_as(Expr::not_exists(Query::select().column(Char::Id).from(Char::Table).take()), "character_exists")
    .expr_as(Expr::not_exists(Query::select().column(Glyph::Id).from(Glyph::Table).take()), "glyph_exists")
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT NOT EXISTS(SELECT `id` FROM `character`) AS `character_exists`, NOT EXISTS(SELECT `id` FROM `glyph`) AS `glyph_exists`"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT NOT EXISTS(SELECT "id" FROM "character") AS "character_exists", NOT EXISTS(SELECT "id" FROM "glyph") AS "glyph_exists""#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT NOT EXISTS(SELECT "id" FROM "character") AS "character_exists", NOT EXISTS(SELECT "id" FROM "glyph") AS "glyph_exists""#
);
Source

pub fn any(sel: SelectStatement) -> Expr

Express a ANY sub-query expression.

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .column(Char::Id)
    .from(Char::Table)
    .and_where(Expr::col(Char::Id).eq(Expr::any(
        Query::select().column(Char::Id).from(Char::Table).take(),
    )))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `id` FROM `character` WHERE `id` = ANY(SELECT `id` FROM `character`)"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "id" FROM "character" WHERE "id" = ANY(SELECT "id" FROM "character")"#
);
Source

pub fn some(sel: SelectStatement) -> Expr

Express a SOME sub-query expression.

§Examples
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .column(Char::Id)
    .from(Char::Table)
    .and_where(Expr::col(Char::Id).ne(Expr::some(
        Query::select().column(Char::Id).from(Char::Table).take(),
    )))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `id` FROM `character` WHERE `id` <> SOME(SELECT `id` FROM `character`)"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "id" FROM "character" WHERE "id" <> SOME(SELECT "id" FROM "character")"#
);
Source

pub fn all(sel: SelectStatement) -> Expr

Express a ALL sub-query expression.

Source

pub fn case<C, T>(cond: C, then: T) -> CaseStatement
where C: IntoCondition, T: Into<Expr>,

Adds new CASE WHEN to existing case statement.

§Examples
use sea_query::{*, tests_cfg::*};

let query = Query::select()
    .expr_as(
        Expr::case(
                Expr::col((Glyph::Table, Glyph::Aspect)).is_in([2, 4]),
                true
             )
            .finally(false),
         "is_even"
    )
    .from(Glyph::Table)
    .to_owned();

assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT (CASE WHEN ("glyph"."aspect" IN (2, 4)) THEN TRUE ELSE FALSE END) AS "is_even" FROM "glyph""#
);
Source

pub fn null() -> Expr

Keyword NULL.

§Examples
use sea_query::*;

let query = Query::select().expr(Expr::null()).to_owned();

assert_eq!(query.to_string(MysqlQueryBuilder), r#"SELECT NULL"#);
assert_eq!(query.to_string(PostgresQueryBuilder), r#"SELECT NULL"#);
assert_eq!(query.to_string(SqliteQueryBuilder), r#"SELECT NULL"#);
Source

pub fn current_date() -> Expr

Keyword CURRENT_DATE.

§Examples
use sea_query::*;

let query = Query::select().expr(Expr::current_date()).to_owned();

assert_eq!(query.to_string(MysqlQueryBuilder), r#"SELECT CURRENT_DATE"#);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT CURRENT_DATE"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT CURRENT_DATE"#
);
Source

pub fn current_time() -> Expr

Keyword CURRENT_TIMESTAMP.

§Examples
use sea_query::*;

let query = Query::select().expr(Expr::current_time()).to_owned();

assert_eq!(query.to_string(MysqlQueryBuilder), r#"SELECT CURRENT_TIME"#);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT CURRENT_TIME"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT CURRENT_TIME"#
);
Source

pub fn current_timestamp() -> Expr

Keyword CURRENT_TIMESTAMP.

§Examples
use sea_query::{Expr, MysqlQueryBuilder, PostgresQueryBuilder, Query, SqliteQueryBuilder};

let query = Query::select().expr(Expr::current_timestamp()).to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT CURRENT_TIMESTAMP"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT CURRENT_TIMESTAMP"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT CURRENT_TIMESTAMP"#
);
Source

pub fn keyword_default() -> Expr

Keyword DEFAULT.

SQLite does not support VALUES ​​(DEFAULT).

§Examples
use sea_query::{
    Expr, MysqlQueryBuilder, PostgresQueryBuilder, Query, SqliteQueryBuilder, tests_cfg::*,
};

let query = Query::insert()
    .columns([Char::Id])
    .values_panic([Expr::keyword_default()])
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"INSERT (`id`) VALUES (DEFAULT)"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"INSERT ("id") VALUES (DEFAULT)"#
);
Source

pub fn custom_keyword<T>(i: T) -> Expr
where T: IntoIden,

Custom keyword.

§Examples
use sea_query::*;

let query = Query::select()
    .expr(Expr::custom_keyword("test"))
    .to_owned();

assert_eq!(query.to_string(MysqlQueryBuilder), r#"SELECT test"#);
assert_eq!(query.to_string(PostgresQueryBuilder), r#"SELECT test"#);
assert_eq!(query.to_string(SqliteQueryBuilder), r#"SELECT test"#);

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl ColumnAsExpr for Expr

Source§

fn into_column_as_expr(self) -> Expr

Casting ActiveEnum as TEXT in select expression, otherwise same as IntoSimpleExpr::into_simple_expr
Source§

impl Debug for Expr

Source§

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

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

impl From<Builder> for Expr

Source§

fn from(builder: Builder) -> Expr

Converts to this type from the input type.
Source§

impl From<Builder> for Expr

Source§

fn from(builder: Builder) -> Expr

Converts to this type from the input type.
Source§

impl From<Builder> for Expr

Source§

fn from(value: Builder) -> Expr

Converts to this type from the input type.
Source§

impl From<Builder> for Expr

Source§

fn from(builder: Builder) -> Expr

Converts to this type from the input type.
Source§

impl From<ColumnRef> for Expr

Source§

fn from(col: ColumnRef) -> Expr

Converts to this type from the input type.
Source§

impl From<Condition> for Expr

Source§

fn from(cond: Condition) -> Expr

Converts to this type from the input type.
Source§

impl From<ConditionExpression> for Expr

Source§

fn from(ce: ConditionExpression) -> Expr

Converts to this type from the input type.
Source§

impl From<DeleteStatement> for Expr

Source§

fn from(v: DeleteStatement) -> Expr

Converts to this type from the input type.
Source§

impl From<Expr> for Condition

Source§

fn from(expr: Expr) -> Condition

Converts to this type from the input type.
Source§

impl From<Expr> for IndexColumn

Source§

fn from(value: Expr) -> IndexColumn

Converts to this type from the input type.
Source§

impl From<FunctionCall> for Expr

Source§

fn from(func: FunctionCall) -> Expr

Converts to this type from the input type.
Source§

impl From<InsertStatement> for Expr

Source§

fn from(v: InsertStatement) -> Expr

Converts to this type from the input type.
Source§

impl From<Keyword> for Expr

Source§

fn from(k: Keyword) -> Expr

Converts to this type from the input type.
Source§

impl From<LikeExpr> for Expr

Source§

fn from(like: LikeExpr) -> Expr

Converts to this type from the input type.
Source§

impl From<SelectStatement> for Expr

Source§

fn from(v: SelectStatement) -> Expr

Converts to this type from the input type.
Source§

impl From<SubQueryStatement> for Expr

Source§

fn from(v: SubQueryStatement) -> Expr

Converts to this type from the input type.
Source§

impl<T> From<T> for Expr
where T: Into<Value>,

Source§

fn from(v: T) -> Expr

Converts to this type from the input type.
Source§

impl From<TypeRef> for Expr

Source§

fn from(type_name: TypeRef) -> Expr

Converts to this type from the input type.
Source§

impl From<UpdateStatement> for Expr

Source§

fn from(v: UpdateStatement) -> Expr

Converts to this type from the input type.
Source§

impl From<Vec<Value>> for Expr

Source§

fn from(v: Vec<Value>) -> Expr

Converts to this type from the input type.
Source§

impl From<WithQuery> for Expr

Source§

fn from(v: WithQuery) -> Expr

Converts to this type from the input type.
Source§

impl Into<Expr> for CaseStatement

Source§

fn into(self) -> Expr

Converts this type into the (usually inferred) input type.
Source§

impl IntoSimpleExpr for Expr

Source§

fn into_simple_expr(self) -> Expr

Method to perform the conversion
Source§

impl PartialEq for Expr

Source§

fn eq(&self, other: &Expr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Expr

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§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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> ExprTrait for T
where T: Into<Expr>,

Source§

fn as_enum<N>(self, type_name: N) -> Expr
where N: IntoIden,

Express a AS enum expression. Read more
Source§

fn binary<O, R>(self, op: O, right: R) -> Expr
where O: Into<BinOper>, R: Into<Expr>,

Create any binary operation Read more
Source§

fn cast_as<N>(self, type_name: N) -> Expr
where N: IntoIden,

Express a CAST AS expression. Read more
Source§

fn unary(self, op: UnOper) -> Expr

Apply any unary operator to the expression. Read more
Source§

fn max(self) -> Expr

Express a MAX function. Read more
Source§

fn min(self) -> Expr

Express a MIN function. Read more
Source§

fn sum(self) -> Expr

Express a SUM function. Read more
Source§

fn avg(self) -> Expr

Express a AVG (average) function. Read more
Source§

fn count(self) -> Expr

Express a COUNT function. Read more
Source§

fn count_distinct(self) -> Expr

Express a COUNT function with the DISTINCT modifier. Read more
Source§

fn if_null<V>(self, v: V) -> Expr
where V: Into<Expr>,

Express a IF NULL function. Read more
Source§

fn add<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express an arithmetic addition operation. Read more
Source§

fn and<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a logical AND operation. Read more
Source§

fn between<A, B>(self, a: A, b: B) -> Expr
where A: Into<Expr>, B: Into<Expr>,

Express a BETWEEN expression. Read more
Source§

fn div<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express an arithmetic division operation. Read more
Source§

fn eq<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express an equal (=) expression. Read more
Source§

fn equals<C>(self, col: C) -> Expr
where C: IntoColumnRef,

Express a equal expression between two table columns, you will mainly use this to relate identical value between two table columns. Read more
Source§

fn gt<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a greater than (>) expression. Read more
Source§

fn gte<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a greater than or equal (>=) expression. Read more
Source§

fn in_subquery(self, sel: SelectStatement) -> Expr

Express a IN sub-query expression. Read more
Source§

fn in_tuples<V, I>(self, v: I) -> Expr
where V: IntoValueTuple, I: IntoIterator<Item = V>,

Express a IN sub expression. Read more
Source§

fn is<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a IS expression. Read more
Source§

fn is_in<V, I>(self, v: I) -> Expr
where V: Into<Expr>, I: IntoIterator<Item = V>,

Express a IN expression. Read more
Source§

fn is_not<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a IS NOT expression. Read more
Source§

fn is_not_in<V, I>(self, v: I) -> Expr
where V: Into<Expr>, I: IntoIterator<Item = V>,

Express a NOT IN expression. Read more
Source§

fn is_not_null(self) -> Expr

Express a IS NOT NULL expression. Read more
Source§

fn is_null(self) -> Expr

Express a IS NULL expression. Read more
Source§

fn left_shift<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a bitwise left shift. Read more
Source§

fn like<L>(self, like: L) -> Expr
where L: IntoLikeExpr,

Express a LIKE expression. Read more
Source§

fn lt<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a less than (<) expression. Read more
Source§

fn lte<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a less than or equal (<=) expression. Read more
Source§

fn modulo<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express an arithmetic modulo operation. Read more
Source§

fn mul<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express an arithmetic multiplication operation. Read more
Source§

fn ne<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a not equal (<>) expression. Read more
Source§

fn not(self) -> Expr

Negates an expression with NOT. Read more
Source§

fn not_between<A, B>(self, a: A, b: B) -> Expr
where A: Into<Expr>, B: Into<Expr>,

Express a NOT BETWEEN expression. Read more
Source§

fn not_equals<C>(self, col: C) -> Expr
where C: IntoColumnRef,

Express a not equal expression between two table columns, you will mainly use this to relate identical value between two table columns. Read more
Source§

fn not_in_subquery(self, sel: SelectStatement) -> Expr

Express a NOT IN sub-query expression. Read more
Source§

fn not_like<L>(self, like: L) -> Expr
where L: IntoLikeExpr,

Express a NOT LIKE expression. Read more
Source§

fn or<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a logical OR operation. Read more
Source§

fn right_shift<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a bitwise right shift. Read more
Source§

fn sub<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express an arithmetic subtraction operation. Read more
Source§

fn bit_and<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a bitwise AND operation. Read more
Source§

fn bit_or<R>(self, right: R) -> Expr
where R: Into<Expr>,

Express a bitwise OR operation. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

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> IntoCondition for T
where T: Into<Condition>,

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoIndexColumn for T
where T: Into<IndexColumn>,

Source§

impl<T> PgExpr for T
where T: ExprTrait,

Source§

fn concatenate<T>(self, right: T) -> Expr
where T: Into<Expr>,

Express an postgres concatenate (||) expression. Read more
Source§

fn concat<T>(self, right: T) -> Expr
where T: Into<Expr>,

Source§

fn matches<T>(self, expr: T) -> Expr
where T: Into<Expr>,

Express an postgres fulltext search matches (@@) expression. Read more
Source§

fn contains<T>(self, expr: T) -> Expr
where T: Into<Expr>,

Express an postgres fulltext search contains (@>) expression. Read more
Source§

fn contained<T>(self, expr: T) -> Expr
where T: Into<Expr>,

Express an postgres fulltext search contained (<@) expression. Read more
Source§

fn ilike<L>(self, like: L) -> Expr
where L: IntoLikeExpr,

Express a ILIKE expression. Read more
Source§

fn not_ilike<L>(self, like: L) -> Expr
where L: IntoLikeExpr,

Express a NOT ILIKE expression
Source§

fn get_json_field<T>(self, right: T) -> Expr
where T: Into<Expr>,

Express a postgres retrieves JSON field as JSON value (->). Read more
Source§

fn cast_json_field<T>(self, right: T) -> Expr
where T: Into<Expr>,

Express a postgres retrieves JSON field and casts it to an appropriate SQL type (->>). Read more
Source§

impl<T> SqliteExpr for T
where T: ExprTrait,

Source§

fn glob<T>(self, right: T) -> Expr
where T: Into<Expr>,

Express an sqlite GLOB operator. Read more
Source§

fn matches<T>(self, right: T) -> Expr
where T: Into<Expr>,

Express an sqlite MATCH operator. Read more
Source§

fn get_json_field<T>(self, right: T) -> Expr
where T: Into<Expr>,

Express an sqlite retrieves JSON field as JSON value (->). Read more
Source§

fn cast_json_field<T>(self, right: T) -> Expr
where T: Into<Expr>,

Express an sqlite retrieves JSON field and casts it to an appropriate SQL type (->>). Read more
§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more