pub struct Expr { /* private fields */ }
Expand description
Helper to build a SimpleExpr
.
Implementationsยง
Sourceยงimpl Expr
impl Expr
pub fn asterisk() -> Expr
Asterisk
]Sourcepub fn col<T>(n: T) -> Exprwhere
T: IntoColumnRef,
pub fn col<T>(n: T) -> Exprwhere
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"#
);
Sourcepub fn tuple<I>(n: I) -> Exprwhere
I: IntoIterator<Item = SimpleExpr>,
pub fn tuple<I>(n: I) -> Exprwhere
I: IntoIterator<Item = SimpleExpr>,
Wraps tuple of SimpleExpr
, 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)"#
);
pub fn table_asterisk<T>(t: T) -> Exprwhere
T: IntoIden,
Asterisk
]Sourcepub fn val<V>(v: V) -> Expr
pub fn val<V>(v: V) -> 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::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'"#
);
Sourcepub fn expr<T>(expr: T) -> Exprwhere
T: Into<SimpleExpr>,
pub fn expr<T>(expr: T) -> Exprwhere
T: Into<SimpleExpr>,
Wrap a SimpleExpr
and perform some operation on it.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.columns([Char::Character, Char::SizeW, Char::SizeH])
.from(Char::Table)
.and_where(Expr::expr(Expr::col(Char::SizeW).if_null(0)).gt(2))
.to_owned();
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)
.and_where(Expr::expr(Func::lower(Expr::col(Char::Character))).is_in(["a", "b"]))
.to_owned();
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')"#
);
Sourcepub fn value<V>(v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn value<V>(v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a Value
, returning a SimpleExpr
.
ยง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'"#
);
Sourcepub fn cust<T>(s: T) -> SimpleExpr
pub fn cust<T>(s: T) -> SimpleExpr
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"#
);
Sourcepub fn cust_with_values<T, V, I>(s: T, v: I) -> SimpleExpr
pub fn cust_with_values<T, V, I>(s: T, v: I) -> SimpleExpr
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)"#
);
Sourcepub fn cust_with_expr<T, E>(s: T, expr: E) -> SimpleExpr
pub fn cust_with_expr<T, E>(s: T, expr: E) -> SimpleExpr
Express any custom expression with SimpleExpr
. 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")"#
);
Sourcepub fn cust_with_exprs<T, I>(s: T, v: I) -> SimpleExpr
pub fn cust_with_exprs<T, I>(s: T, v: I) -> SimpleExpr
Express any custom expression with SimpleExpr
. Use this if your expression needs other expressions.
Sourcepub fn eq<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn eq<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express an equal (=
) expression.
This is equivalent to a newer ExprTrait::eq and may require more some wrapping beforehand.
ยงExamples
use sea_query::{*, tests_cfg::*};
let query = Query::select()
.columns([Char::Character, Char::SizeW, Char::SizeH])
.from(Char::Table)
.and_where(Expr::val("What!").eq("Nothing"))
.and_where(Expr::col(Char::Id).eq(1))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 'What!' = 'Nothing' AND `id` = 1"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 'What!' = 'Nothing' AND "id" = 1"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 'What!' = 'Nothing' AND "id" = 1"#
);
Sourcepub fn ne<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn ne<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a not equal (<>
) expression.
This is equivalent to a newer ExprTrait::ne and may require more some wrapping beforehand.
ยงExamples
use sea_query::{*, tests_cfg::*};
let query = Query::select()
.columns([Char::Character, Char::SizeW, Char::SizeH])
.from(Char::Table)
.and_where(Expr::val("Morning").ne("Good"))
.and_where(Expr::col(Char::Id).ne(1))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 'Morning' <> 'Good' AND `id` <> 1"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 'Morning' <> 'Good' AND "id" <> 1"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 'Morning' <> 'Good' AND "id" <> 1"#
);
Sourcepub fn equals<C>(self, col: C) -> SimpleExprwhere
C: IntoColumnRef,
pub fn equals<C>(self, col: C) -> SimpleExprwhere
C: IntoColumnRef,
Express a equal expression between two table columns, you will mainly use this to relate identical value between two table columns.
This is equivalent to a newer ExprTrait::equals and may require more some wrapping beforehand.
ยง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::Table, Char::FontId)).equals((Font::Table, Font::Id)))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`font_id` = `font`.`id`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."font_id" = "font"."id""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."font_id" = "font"."id""#
);
Sourcepub fn not_equals<C>(self, col: C) -> SimpleExprwhere
C: IntoColumnRef,
pub fn not_equals<C>(self, col: C) -> SimpleExprwhere
C: IntoColumnRef,
Express a not equal expression between two table columns, you will mainly use this to relate identical value between two table columns.
This is equivalent to a newer ExprTrait::not_equals and may require more some wrapping beforehand.
ยง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::Table, Char::FontId)).not_equals((Font::Table, Font::Id)))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`font_id` <> `font`.`id`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."font_id" <> "font"."id""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."font_id" <> "font"."id""#
);
Sourcepub fn gt<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn gt<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a greater than (>
) expression.
This is equivalent to a newer ExprTrait::gt and may require more some wrapping beforehand.
ยง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::Table, Char::SizeW)).gt(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` > 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" > 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" > 2"#
);
Sourcepub fn gte<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn gte<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a greater than or equal (>=
) expression.
This is equivalent to a newer ExprTrait::gte and may require more some wrapping beforehand.
ยง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::Table, Char::SizeW)).gte(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` >= 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" >= 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" >= 2"#
);
Sourcepub fn lt<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn lt<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a less than (<
) expression.
This is equivalent to a newer ExprTrait::lt and may require more some wrapping beforehand.
ยง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::Table, Char::SizeW)).lt(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` < 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" < 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" < 2"#
);
Sourcepub fn lte<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn lte<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a less than or equal (<=
) expression.
This is equivalent to a newer ExprTrait::lte and may require more some wrapping beforehand.
ยง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::Table, Char::SizeW)).lte(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` <= 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" <= 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" <= 2"#
);
Sourcepub fn add<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn add<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express an arithmetic addition operation.
This is equivalent to a newer ExprTrait::add and may require more some wrapping beforehand.
ยง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).add(1).eq(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 + 1 = 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 + 1 = 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 + 1 = 2"#
);
Sourcepub fn sub<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn sub<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express an arithmetic subtraction operation.
This is equivalent to a newer ExprTrait::sub and may require more some wrapping beforehand.
ยง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).sub(1).eq(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 - 1 = 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 - 1 = 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 - 1 = 2"#
);
Sourcepub fn mul<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn mul<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express an arithmetic multiplication operation.
This is equivalent to a newer ExprTrait::mul and may require more some wrapping beforehand.
ยง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).mul(1).eq(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 * 1 = 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 * 1 = 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 * 1 = 2"#
);
Sourcepub fn div<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn div<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express an arithmetic division operation.
This is equivalent to a newer ExprTrait::div and may require more some wrapping beforehand.
ยง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).div(1).eq(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 / 1 = 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 / 1 = 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 / 1 = 2"#
);
Sourcepub fn modulo<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn modulo<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express an arithmetic modulo operation.
This is equivalent to a newer ExprTrait::modulo and may require more some wrapping beforehand.
ยง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).modulo(1).eq(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 % 1 = 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 % 1 = 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 % 1 = 2"#
);
Sourcepub fn left_shift<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn left_shift<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a bitwise left shift.
This is equivalent to a newer ExprTrait::left_shift and may require more some wrapping beforehand.
ยง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).left_shift(1).eq(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 << 1 = 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 << 1 = 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 << 1 = 2"#
);
Sourcepub fn right_shift<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn right_shift<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a bitwise right shift.
This is equivalent to a newer ExprTrait::right_shift and may require more some wrapping beforehand.
ยง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).right_shift(1).eq(2))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE 1 >> 1 = 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 >> 1 = 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE 1 >> 1 = 2"#
);
Sourcepub fn between<V>(self, a: V, b: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn between<V>(self, a: V, b: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a BETWEEN
expression.
This is equivalent to a newer ExprTrait::between and may require more some wrapping beforehand.
ยง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::Table, Char::SizeW)).between(1, 10))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` BETWEEN 1 AND 10"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" BETWEEN 1 AND 10"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" BETWEEN 1 AND 10"#
);
Sourcepub fn not_between<V>(self, a: V, b: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn not_between<V>(self, a: V, b: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a NOT BETWEEN
expression.
This is equivalent to a newer ExprTrait::not_between and may require more some wrapping beforehand.
ยง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::Table, Char::SizeW)).not_between(1, 10))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` NOT BETWEEN 1 AND 10"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" NOT BETWEEN 1 AND 10"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" NOT BETWEEN 1 AND 10"#
);
Sourcepub fn like<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
pub fn like<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
Express a LIKE
expression.
This is equivalent to a newer ExprTrait::like and may require more some wrapping beforehand.
ยง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::Table, Char::Character)).like("Ours'%"))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`character` LIKE 'Ours\'%'"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."character" LIKE E'Ours\'%'"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."character" LIKE 'Ours''%'"#
);
Like with ESCAPE
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::Character)).like(LikeExpr::new(r"|_Our|_").escape('|')))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`character` LIKE '|_Our|_' ESCAPE '|'"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."character" LIKE '|_Our|_' ESCAPE '|'"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."character" LIKE '|_Our|_' ESCAPE '|'"#
);
Sourcepub fn not_like<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
pub fn not_like<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
Express a NOT LIKE
expression.
This is equivalent to a newer ExprTrait::not_like and may require more some wrapping beforehand.
Sourcepub fn is_null(self) -> SimpleExpr
pub fn is_null(self) -> SimpleExpr
Express a IS NULL
expression.
This is equivalent to a newer ExprTrait::is_null and may require more some wrapping beforehand.
ยง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::Table, Char::SizeW)).is_null())
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` IS NULL"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" IS NULL"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" IS NULL"#
);
Sourcepub fn is<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn is<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a IS
expression.
This is equivalent to a newer ExprTrait::is and may require more some wrapping beforehand.
ยง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::Table, Char::Ascii)).is(true))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`ascii` IS TRUE"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."ascii" IS TRUE"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."ascii" IS TRUE"#
);
Sourcepub fn is_not_null(self) -> SimpleExpr
pub fn is_not_null(self) -> SimpleExpr
Express a IS NOT NULL
expression.
This is equivalent to a newer ExprTrait::is_not_null and may require more some wrapping beforehand.
ยง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::Table, Char::SizeW)).is_not_null())
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`size_w` IS NOT NULL"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" IS NOT NULL"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."size_w" IS NOT NULL"#
);
Sourcepub fn is_not<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn is_not<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a IS NOT
expression.
This is equivalent to a newer ExprTrait::is_not and may require more some wrapping beforehand.
ยง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::Table, Char::Ascii)).is_not(true))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `character`.`ascii` IS NOT TRUE"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."ascii" IS NOT TRUE"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "character"."ascii" IS NOT TRUE"#
);
Sourcepub fn binary<O, T>(self, op: O, right: T) -> SimpleExpr
pub fn binary<O, T>(self, op: O, right: T) -> SimpleExpr
Create any binary operation
This is equivalent to a newer ExprTrait::binary and may require more some wrapping beforehand.
ยงExamples
use sea_query::{*, tests_cfg::*};
let query = Query::select()
.columns([Char::Character, Char::SizeW, Char::SizeH])
.from(Char::Table)
.cond_where(all![
Expr::col(Char::SizeW).binary(BinOper::SmallerThan, 10),
Expr::col(Char::SizeW).binary(BinOper::GreaterThan, Expr::col(Char::SizeH))
])
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `size_w` < 10 AND `size_w` > `size_h`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" < 10 AND "size_w" > "size_h""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" < 10 AND "size_w" > "size_h""#
);
Sourcepub fn not(self) -> SimpleExpr
pub fn not(self) -> SimpleExpr
Negates an expression with NOT
.
This is equivalent to a newer ExprTrait::not and may require more some wrapping beforehand.
ยงExamples
use sea_query::{*, tests_cfg::*};
let query = Query::select()
.columns([Char::Character, Char::SizeW, Char::SizeH])
.from(Char::Table)
.and_where(Expr::expr(Expr::col((Char::Table, Char::SizeW)).is_null()).not())
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE NOT `character`.`size_w` IS NULL"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE NOT "character"."size_w" IS NULL"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE NOT "character"."size_w" IS NULL"#
);
Sourcepub fn max(self) -> SimpleExpr
pub fn max(self) -> SimpleExpr
Express a MAX
function.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.expr(Expr::col((Char::Table, Char::SizeW)).max())
.from(Char::Table)
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT MAX(`character`.`size_w`) FROM `character`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT MAX("character"."size_w") FROM "character""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT MAX("character"."size_w") FROM "character""#
);
Sourcepub fn min(self) -> SimpleExpr
pub fn min(self) -> SimpleExpr
Express a MIN
function.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.expr(Expr::col((Char::Table, Char::SizeW)).min())
.from(Char::Table)
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT MIN(`character`.`size_w`) FROM `character`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT MIN("character"."size_w") FROM "character""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT MIN("character"."size_w") FROM "character""#
);
Sourcepub fn sum(self) -> SimpleExpr
pub fn sum(self) -> SimpleExpr
Express a SUM
function.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.expr(Expr::col((Char::Table, Char::SizeW)).sum())
.from(Char::Table)
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT SUM(`character`.`size_w`) FROM `character`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT SUM("character"."size_w") FROM "character""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT SUM("character"."size_w") FROM "character""#
);
Sourcepub fn count(self) -> SimpleExpr
pub fn count(self) -> SimpleExpr
Express a COUNT
function.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.expr(Expr::col((Char::Table, Char::SizeW)).count())
.from(Char::Table)
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT COUNT(`character`.`size_w`) FROM `character`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT COUNT("character"."size_w") FROM "character""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT COUNT("character"."size_w") FROM "character""#
);
Sourcepub fn count_distinct(self) -> SimpleExpr
pub fn count_distinct(self) -> SimpleExpr
Express a COUNT
function with the DISTINCT modifier.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.expr(Expr::col((Char::Table, Char::SizeW)).count_distinct())
.from(Char::Table)
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT COUNT(DISTINCT `character`.`size_w`) FROM `character`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT COUNT(DISTINCT "character"."size_w") FROM "character""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT COUNT(DISTINCT "character"."size_w") FROM "character""#
);
Sourcepub fn if_null<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
pub fn if_null<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Express a IF NULL
function.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.expr(Expr::col((Char::Table, Char::SizeW)).if_null(0))
.from(Char::Table)
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT IFNULL(`character`.`size_w`, 0) FROM `character`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT COALESCE("character"."size_w", 0) FROM "character""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT IFNULL("character"."size_w", 0) FROM "character""#
);
Sourcepub fn is_in<V, I>(self, v: I) -> SimpleExpr
pub fn is_in<V, I>(self, v: I) -> SimpleExpr
Express a IN
expression.
This is equivalent to a newer ExprTrait::is_in and may require more some wrapping beforehand.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.columns([Char::Id])
.from(Char::Table)
.and_where(Expr::col((Char::Table, Char::SizeW)).is_in([1, 2, 3]))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `id` FROM `character` WHERE `character`.`size_w` IN (1, 2, 3)"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "id" FROM "character" WHERE "character"."size_w" IN (1, 2, 3)"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "id" FROM "character" WHERE "character"."size_w" IN (1, 2, 3)"#
);
Empty value list
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.columns([Char::Id])
.from(Char::Table)
.and_where(Expr::col((Char::Table, Char::SizeW)).is_in(Vec::<u8>::new()))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `id` FROM `character` WHERE 1 = 2"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "id" FROM "character" WHERE 1 = 2"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "id" FROM "character" WHERE 1 = 2"#
);
Sourcepub fn in_tuples<V, I>(self, v: I) -> SimpleExprwhere
V: IntoValueTuple,
I: IntoIterator<Item = V>,
pub fn in_tuples<V, I>(self, v: I) -> SimpleExprwhere
V: IntoValueTuple,
I: IntoIterator<Item = V>,
Express a IN
sub expression.
This is equivalent to a newer ExprTrait::in_tuples and may require more some wrapping beforehand.
ยงExamples
use sea_query::{*, tests_cfg::*};
let query = Query::select()
.columns([Char::Character, Char::FontId])
.from(Char::Table)
.and_where(
Expr::tuple([
Expr::col(Char::Character).into(),
Expr::col(Char::FontId).into(),
])
.in_tuples([(1, String::from("1")), (2, String::from("2"))])
)
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `font_id` FROM `character` WHERE (`character`, `font_id`) IN ((1, '1'), (2, '2'))"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "font_id" FROM "character" WHERE ("character", "font_id") IN ((1, '1'), (2, '2'))"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "font_id" FROM "character" WHERE ("character", "font_id") IN ((1, '1'), (2, '2'))"#
);
Sourcepub fn is_not_in<V, I>(self, v: I) -> SimpleExpr
pub fn is_not_in<V, I>(self, v: I) -> SimpleExpr
Express a NOT IN
expression.
This is equivalent to a newer ExprTrait::is_not_in and may require more some wrapping beforehand.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.columns([Char::Id])
.from(Char::Table)
.and_where(Expr::col((Char::Table, Char::SizeW)).is_not_in([1, 2, 3]))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `id` FROM `character` WHERE `character`.`size_w` NOT IN (1, 2, 3)"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "id" FROM "character" WHERE "character"."size_w" NOT IN (1, 2, 3)"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "id" FROM "character" WHERE "character"."size_w" NOT IN (1, 2, 3)"#
);
Empty value list
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.columns([Char::Id])
.from(Char::Table)
.and_where(Expr::col((Char::Table, Char::SizeW)).is_not_in(Vec::<u8>::new()))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `id` FROM `character` WHERE 1 = 1"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "id" FROM "character" WHERE 1 = 1"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "id" FROM "character" WHERE 1 = 1"#
);
Sourcepub fn in_subquery(self, sel: SelectStatement) -> SimpleExpr
pub fn in_subquery(self, sel: SelectStatement) -> SimpleExpr
Express a IN
sub-query expression.
This is equivalent to a newer ExprTrait::in_subquery and may require more some wrapping beforehand.
ยง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).in_subquery(
Query::select()
.expr(Expr::cust("3 + 2 * 2"))
.take()
))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `size_w` IN (SELECT 3 + 2 * 2)"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" IN (SELECT 3 + 2 * 2)"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" IN (SELECT 3 + 2 * 2)"#
);
Sourcepub fn not_in_subquery(self, sel: SelectStatement) -> SimpleExpr
pub fn not_in_subquery(self, sel: SelectStatement) -> SimpleExpr
Express a NOT IN
sub-query expression.
This is equivalent to a newer ExprTrait::not_in_subquery and may require more some wrapping beforehand.
ยง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).not_in_subquery(
Query::select()
.expr(Expr::cust("3 + 2 * 2"))
.take()
))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `character`, `size_w`, `size_h` FROM `character` WHERE `size_w` NOT IN (SELECT 3 + 2 * 2)"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" NOT IN (SELECT 3 + 2 * 2)"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "size_w" NOT IN (SELECT 3 + 2 * 2)"#
);
Sourcepub fn exists(sel: SelectStatement) -> SimpleExpr
pub fn exists(sel: SelectStatement) -> SimpleExpr
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()), Alias::new("character_exists"))
.expr_as(Expr::exists(Query::select().column(Glyph::Id).from(Glyph::Table).take()), Alias::new("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""#
);
Sourcepub fn any(sel: SelectStatement) -> SimpleExpr
pub fn any(sel: SelectStatement) -> SimpleExpr
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")"#
);
Sourcepub fn some(sel: SelectStatement) -> SimpleExpr
pub fn some(sel: SelectStatement) -> SimpleExpr
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")"#
);
Sourcepub fn all(sel: SelectStatement) -> SimpleExpr
pub fn all(sel: SelectStatement) -> SimpleExpr
Express a ALL
sub-query expression.
Sourcepub fn as_enum<T>(self, type_name: T) -> SimpleExprwhere
T: IntoIden,
pub fn as_enum<T>(self, type_name: T) -> SimpleExprwhere
T: IntoIden,
Express a AS enum
expression.
This is equivalent to a newer ExprTrait::as_enum and may require more some wrapping beforehand.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.expr(Expr::col(Char::FontSize).as_enum(Alias::new("text")))
.from(Char::Table)
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT `font_size` FROM `character`"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT CAST("font_size" AS text) FROM "character""#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT "font_size" FROM "character""#
);
let query = Query::insert()
.into_table(Char::Table)
.columns([Char::FontSize])
.values_panic([Expr::val("large").as_enum(Alias::new("FontSizeEnum"))])
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"INSERT INTO `character` (`font_size`) VALUES ('large')"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"INSERT INTO "character" ("font_size") VALUES (CAST('large' AS FontSizeEnum))"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"INSERT INTO "character" ("font_size") VALUES ('large')"#
);
Sourcepub fn case<C, T>(cond: C, then: T) -> CaseStatement
pub fn case<C, T>(cond: C, then: T) -> CaseStatement
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),
Alias::new("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""#
);
Sourcepub fn cast_as<T>(self, type_name: T) -> SimpleExprwhere
T: IntoIden,
pub fn cast_as<T>(self, type_name: T) -> SimpleExprwhere
T: IntoIden,
Express a CAST AS
expression.
This is equivalent to a newer ExprTrait::cast_as and may require more some wrapping beforehand.
ยงExamples
use sea_query::{tests_cfg::*, *};
let query = Query::select()
.expr(Expr::val("1").cast_as(Alias::new("integer")))
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
r#"SELECT CAST('1' AS integer)"#
);
assert_eq!(
query.to_string(PostgresQueryBuilder),
r#"SELECT CAST('1' AS integer)"#
);
assert_eq!(
query.to_string(SqliteQueryBuilder),
r#"SELECT CAST('1' AS integer)"#
);
Sourcepub fn current_date() -> Expr
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"#
);
Sourcepub fn current_time() -> Expr
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"#
);
Sourcepub fn current_timestamp() -> Expr
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"#
);
Sourcepub fn custom_keyword<T>(i: T) -> Exprwhere
T: IntoIden,
pub fn custom_keyword<T>(i: T) -> Exprwhere
T: IntoIden,
Custom keyword.
ยงExamples
use sea_query::*;
let query = Query::select()
.expr(Expr::custom_keyword(Alias::new("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 IntoSimpleExpr for Expr
impl IntoSimpleExpr for Expr
Sourceยงfn into_simple_expr(self) -> SimpleExpr
fn into_simple_expr(self) -> SimpleExpr
Sourceยงimpl PgExpr for Expr
impl PgExpr for Expr
Sourceยงfn concatenate<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn concatenate<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
||
) expression. Read moreSourceยงfn concat<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn concat<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
PgExpr::concatenate
Sourceยงfn matches<T>(self, expr: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn matches<T>(self, expr: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
@@
) expression. Read moreSourceยงfn contains<T>(self, expr: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn contains<T>(self, expr: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
@>
) expression. Read moreSourceยงfn contained<T>(self, expr: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn contained<T>(self, expr: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
<@
) expression. Read moreSourceยงfn ilike<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
fn ilike<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
ILIKE
expression. Read moreSourceยงfn not_ilike<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
fn not_ilike<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
NOT ILIKE
expressionSourceยงfn get_json_field<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn get_json_field<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
->
). Read moreSourceยงfn cast_json_field<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn cast_json_field<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
->>
). Read moreSourceยงimpl SqliteExpr for Expr
impl SqliteExpr for Expr
Sourceยงfn glob<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn glob<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
GLOB
operator. Read moreSourceยงfn matches<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn matches<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
MATCH
operator. Read moreSourceยงfn get_json_field<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn get_json_field<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
->
). Read moreSourceยงfn cast_json_field<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
fn cast_json_field<T>(self, right: T) -> SimpleExprwhere
T: Into<SimpleExpr>,
->>
). Read moreAuto 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> 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
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงunsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Sourceยงimpl<T> ExprTrait for Twhere
T: Into<SimpleExpr>,
impl<T> ExprTrait for Twhere
T: Into<SimpleExpr>,
Sourceยงfn as_enum<N>(self, type_name: N) -> SimpleExprwhere
N: IntoIden,
fn as_enum<N>(self, type_name: N) -> SimpleExprwhere
N: IntoIden,
AS enum
expression. Read moreSourceยงfn binary<O, R>(self, op: O, right: R) -> SimpleExpr
fn binary<O, R>(self, op: O, right: R) -> SimpleExpr
Sourceยงfn cast_as<N>(self, type_name: N) -> SimpleExprwhere
N: IntoIden,
fn cast_as<N>(self, type_name: N) -> SimpleExprwhere
N: IntoIden,
CAST AS
expression. Read moreSourceยงfn unary(self, op: UnOper) -> SimpleExpr
fn unary(self, op: UnOper) -> SimpleExpr
Sourceยงfn add<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn add<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn and<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
Sourceยงfn between<A, B>(self, a: A, b: B) -> SimpleExpr
fn between<A, B>(self, a: A, b: B) -> SimpleExpr
BETWEEN
expression. Read moreSourceยงfn div<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn div<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
Sourceยงfn eq<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn eq<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
=
) expression. Read moreSourceยงfn equals<C>(self, col: C) -> SimpleExprwhere
C: IntoColumnRef,
fn equals<C>(self, col: C) -> SimpleExprwhere
C: IntoColumnRef,
Sourceยงfn gt<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn gt<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
>
) expression. Read moreSourceยงfn gte<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn gte<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
>=
) expression. Read moreSourceยงfn in_subquery(self, sel: SelectStatement) -> SimpleExpr
fn in_subquery(self, sel: SelectStatement) -> SimpleExpr
IN
sub-query expression. Read moreSourceยงfn in_tuples<V, I>(self, v: I) -> SimpleExprwhere
V: IntoValueTuple,
I: IntoIterator<Item = V>,
fn in_tuples<V, I>(self, v: I) -> SimpleExprwhere
V: IntoValueTuple,
I: IntoIterator<Item = V>,
IN
sub expression. Read moreSourceยงfn is<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn is<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
IS
expression. Read moreSourceยงfn is_in<V, I>(self, v: I) -> SimpleExpr
fn is_in<V, I>(self, v: I) -> SimpleExpr
IN
expression. Read moreSourceยงfn is_not<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn is_not<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
IS NOT
expression. Read moreSourceยงfn is_not_in<V, I>(self, v: I) -> SimpleExpr
fn is_not_in<V, I>(self, v: I) -> SimpleExpr
NOT IN
expression. Read moreSourceยงfn is_not_null(self) -> SimpleExpr
fn is_not_null(self) -> SimpleExpr
IS NOT NULL
expression. Read moreSourceยงfn is_null(self) -> SimpleExpr
fn is_null(self) -> SimpleExpr
IS NULL
expression. Read moreSourceยงfn left_shift<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn left_shift<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
Sourceยงfn like<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
fn like<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
LIKE
expression. Read moreSourceยงfn lt<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn lt<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
<
) expression. Read moreSourceยงfn lte<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn lte<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
<=
) expression. Read moreSourceยงfn modulo<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn modulo<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
Sourceยงfn mul<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn mul<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
Sourceยงfn ne<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn ne<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
<>
) expression. Read moreSourceยงfn not(self) -> SimpleExpr
fn not(self) -> SimpleExpr
NOT
. Read moreSourceยงfn not_between<A, B>(self, a: A, b: B) -> SimpleExpr
fn not_between<A, B>(self, a: A, b: B) -> SimpleExpr
NOT BETWEEN
expression. Read moreSourceยงfn not_equals<C>(self, col: C) -> SimpleExprwhere
C: IntoColumnRef,
fn not_equals<C>(self, col: C) -> SimpleExprwhere
C: IntoColumnRef,
Sourceยงfn not_in_subquery(self, sel: SelectStatement) -> SimpleExpr
fn not_in_subquery(self, sel: SelectStatement) -> SimpleExpr
NOT IN
sub-query expression. Read moreSourceยงfn not_like<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
fn not_like<L>(self, like: L) -> SimpleExprwhere
L: IntoLikeExpr,
NOT LIKE
expression. Read moreSourceยงfn or<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn or<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
OR
operation. Read moreSourceยงfn right_shift<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn right_shift<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
Sourceยงfn sub<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
fn sub<R>(self, right: R) -> SimpleExprwhere
R: Into<SimpleExpr>,
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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