Skip to main content

InsertStatement

Struct InsertStatement 

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

Insert any new rows into an existing table

§Examples

use sql_builder::*;

let query = Query::insert()
    .into_table("glyph")
    .columns(["aspect", "image"])
    .values_panic([5.15.into(), "12A".into()])
    .values_panic([4.21.into(), "123".into()])
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"INSERT INTO `glyph` (`aspect`, `image`) VALUES (5.15, '12A'), (4.21, '123')"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (5.15, '12A'), (4.21, '123')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (5.15, '12A'), (4.21, '123')"#
);

Implementations§

Source§

impl InsertStatement

Source

pub fn build_any( &self, query_builder: &impl QueryBuilder, ) -> Result<(String, Values), RenderError>

Source

pub fn build_collect_any( &self, query_builder: &impl QueryBuilder, sql: &mut impl SqlWriter, ) -> Result<String, RenderError>

Source

pub fn build_collect_any_into( &self, query_builder: &impl QueryBuilder, sql: &mut impl SqlWriter, ) -> Result<(), RenderError>

Source§

impl InsertStatement

Source

pub fn to_string<T: QueryBuilder>( &self, query_builder: T, ) -> Result<String, RenderError>

Source

pub fn build<T: QueryBuilder>( &self, query_builder: T, ) -> Result<(String, Values), RenderError>

Source

pub fn build_collect<T: QueryBuilder>( &self, query_builder: T, sql: &mut impl SqlWriter, ) -> Result<String, RenderError>

Source

pub fn build_collect_into<T: QueryBuilder>( &self, query_builder: T, sql: &mut impl SqlWriter, ) -> Result<(), RenderError>

Source§

impl InsertStatement

Source

pub fn on_conflict(&mut self, on_conflict: OnConflict) -> &mut Self

ON CONFLICT expression

§Examples
Source

pub fn has_on_conflict(&self) -> bool

Whether the statement says what to do on a conflict.

Source

pub fn returning(&mut self, returning: ReturningClause) -> &mut Self

RETURNING expressions.

§Examples
use sql_builder::*;

let query = Query::insert()
    .into_table("glyph")
    .columns(["image"])
    .values_panic(["12A".into()])
    .returning(Query::returning().columns(["id"]))
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    "INSERT INTO `glyph` (`image`) VALUES ('12A') RETURNING `id`"
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('12A') RETURNING "id""#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('12A') RETURNING "id""#
);
Source

pub fn returning_col<C>(&mut self, col: C) -> &mut Self
where C: IntoColumnRef,

RETURNING expressions for a column.

§Examples
use sql_builder::*;

let query = Query::insert()
    .into_table("glyph")
    .columns(["image"])
    .values_panic(["12A".into()])
    .returning_col("id")
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    "INSERT INTO `glyph` (`image`) VALUES ('12A') RETURNING `id`"
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('12A') RETURNING "id""#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('12A') RETURNING "id""#
);
Source

pub fn returning_all(&mut self) -> &mut Self

RETURNING expressions all columns.

§Examples
use sql_builder::*;

let query = Query::insert()
    .into_table("glyph")
    .columns(["image"])
    .values_panic(["12A".into()])
    .returning_all()
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    "INSERT INTO `glyph` (`image`) VALUES ('12A') RETURNING *"
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('12A') RETURNING *"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('12A') RETURNING *"#
);
Source

pub fn with(self, clause: WithClause) -> WithQuery

Create a WithQuery by specifying a WithClause to execute this query with.

§Examples
use sql_builder::{*, IntoCondition, IntoIden};

let select = SelectStatement::new()
        .columns(["id", "image", "aspect"])
        .from("glyph")
        .take();
    let cte = CommonTableExpression::new()
        .query(select)
        .column("id")
        .column("image")
        .column("aspect")
        .table_name("cte")
        .to_owned();
    let with_clause = WithClause::new().cte(cte).to_owned();
    let select = SelectStatement::new()
        .columns(["id", "image", "aspect"])
        .from("cte")
        .take();
    let mut insert = Query::insert();
    insert
        .into_table("glyph")
        .columns(["id", "image", "aspect"])
        .select_from(select)
        .unwrap();
    let query = insert.with(with_clause);

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"WITH `cte` (`id`, `image`, `aspect`) AS (SELECT `id`, `image`, `aspect` FROM `glyph`) INSERT INTO `glyph` (`id`, `image`, `aspect`) SELECT `id`, `image`, `aspect` FROM `cte`"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"WITH "cte" ("id", "image", "aspect") AS (SELECT "id", "image", "aspect" FROM "glyph") INSERT INTO "glyph" ("id", "image", "aspect") SELECT "id", "image", "aspect" FROM "cte""#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"WITH "cte" ("id", "image", "aspect") AS (SELECT "id", "image", "aspect" FROM "glyph") INSERT INTO "glyph" ("id", "image", "aspect") SELECT "id", "image", "aspect" FROM "cte""#
);
Source

pub fn with_cte<C: Into<WithClause>>(&mut self, clause: C) -> &mut Self

Create a Common Table Expression by specifying a CommonTableExpression or WithClause to execute this query with.

§Examples
use sql_builder::{*, IntoCondition, IntoIden};

let select = SelectStatement::new()
        .columns(["id", "image", "aspect"])
        .from("glyph")
        .take();
    let cte = CommonTableExpression::new()
        .query(select)
        .column("id")
        .column("image")
        .column("aspect")
        .table_name("cte")
        .to_owned();
    let with_clause = WithClause::new().cte(cte).to_owned();
    let select = SelectStatement::new()
        .columns(["id", "image", "aspect"])
        .from("cte")
        .take();
    let mut query = Query::insert();
    query
        .with_cte(with_clause)
        .into_table("glyph")
        .columns(["id", "image", "aspect"])
        .select_from(select)
        .unwrap();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"WITH `cte` (`id`, `image`, `aspect`) AS (SELECT `id`, `image`, `aspect` FROM `glyph`) INSERT INTO `glyph` (`id`, `image`, `aspect`) SELECT `id`, `image`, `aspect` FROM `cte`"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"WITH "cte" ("id", "image", "aspect") AS (SELECT "id", "image", "aspect" FROM "glyph") INSERT INTO "glyph" ("id", "image", "aspect") SELECT "id", "image", "aspect" FROM "cte""#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"WITH "cte" ("id", "image", "aspect") AS (SELECT "id", "image", "aspect" FROM "glyph") INSERT INTO "glyph" ("id", "image", "aspect") SELECT "id", "image", "aspect" FROM "cte""#
);
Source

pub fn or_default_values(&mut self) -> &mut Self

Insert with default values if columns and values are not supplied.

§Examples
use sql_builder::*;

// Insert default
let query = Query::insert()
    .into_table("glyph")
    .or_default_values()
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"INSERT INTO `glyph` VALUES ()"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" VALUES (DEFAULT)"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" DEFAULT VALUES"#
);

// Ordinary insert as columns and values are supplied
let query = Query::insert()
    .into_table("glyph")
    .or_default_values()
    .columns(["image"])
    .values_panic(["ABC".into()])
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"INSERT INTO `glyph` (`image`) VALUES ('ABC')"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('ABC')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('ABC')"#
);
Source

pub fn or_default_values_many(&mut self, num_rows: usize) -> &mut Self

Insert multiple rows with default values if columns and values are not supplied.

§Examples
use sql_builder::*;

// Insert default
let query = Query::insert()
    .into_table("glyph")
    .or_default_values_many(3)
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"INSERT INTO `glyph` VALUES (), (), ()"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" VALUES (DEFAULT), (DEFAULT), (DEFAULT)"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" (rowid) VALUES (NULL), (NULL), (NULL)"#
);

// Ordinary insert as columns and values are supplied
let query = Query::insert()
    .into_table("glyph")
    .or_default_values_many(3)
    .columns(["image"])
    .values_panic(["ABC".into()])
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"INSERT INTO `glyph` (`image`) VALUES ('ABC')"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('ABC')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") VALUES ('ABC')"#
);
Source§

impl InsertStatement

Source

pub fn new() -> Self

Construct a new InsertStatement

Source

pub fn take(&mut self) -> Self

Take the ownership of data in the current SelectStatement

Source

pub fn replace(&mut self) -> &mut Self

Use REPLACE instead of INSERT. PostgreSQL has none and refuses to render it.

§Examples
use sql_builder::*;

let query = Query::insert()
    .replace()
    .into_table("glyph")
    .columns(["aspect", "image"])
    .values_panic([5.15.into(), "12A".into()])
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"REPLACE INTO `glyph` (`aspect`, `image`) VALUES (5.15, '12A')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"REPLACE INTO "glyph" ("aspect", "image") VALUES (5.15, '12A')"#
);
Source

pub fn into_table<T>(&mut self, tbl_ref: T) -> &mut Self
where T: IntoTableRef,

Specify which table to insert into.

§Examples

See InsertStatement::values

Source

pub fn columns<C, I>(&mut self, columns: I) -> &mut Self
where C: IntoIden, I: IntoIterator<Item = C>,

Specify what columns to insert.

§Examples

See InsertStatement::values

Source

pub fn select_from<S>(&mut self, select: S) -> Result<&mut Self>

Specify a select query whose values to be inserted.

§Examples
use sql_builder::*;

let query = Query::insert()
    .into_table("glyph")
    .columns(["aspect", "image"])
    .select_from(Query::select()
        .column("aspect")
        .column("image")
        .from("glyph")
        .and_where(Expr::col("image").like("0%"))
        .take()
    )
    .unwrap()
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"INSERT INTO `glyph` (`aspect`, `image`) SELECT `aspect`, `image` FROM `glyph` WHERE `image` LIKE '0%'"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") SELECT "aspect", "image" FROM "glyph" WHERE "image" LIKE '0%'"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") SELECT "aspect", "image" FROM "glyph" WHERE "image" LIKE '0%'"#
);
use sql_builder::*;
let query = Query::insert()
    .into_table("glyph")
    .columns(["image"])
    .select_from(
        Query::select()
            .expr(Expr::val("hello"))
            .cond_where(Cond::all().not().add(Expr::exists(
                Query::select().expr(Expr::val("world")).take(),
            )))
            .take(),
    )
    .unwrap()
    .take();

assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") SELECT 'hello' WHERE NOT EXISTS(SELECT 'world')"#
);
use sql_builder::*;
let query = Query::insert()
    .into_table("glyph")
    .columns(["image"])
    .select_from(
        Query::select()
            .expr(Expr::col("name"))
            .from("font")
            .take(),
    )
    .unwrap()
    .take();

assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("image") SELECT "name" FROM "font""#
);
Source

pub fn values<I>(&mut self, values: I) -> Result<&mut Self>
where I: IntoIterator<Item = Expr>,

Specify a row of values to be inserted.

Return error when number of values not matching number of columns.

§Examples
use sql_builder::*;

let query = Query::insert()
    .into_table("glyph")
    .columns(["aspect", "image"])
    .values([
        2.into(),
        Func::cast_as("2020-02-02 00:00:00", "DATE").into(),
    ])
    .unwrap()
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"INSERT INTO `glyph` (`aspect`, `image`) VALUES (2, CAST('2020-02-02 00:00:00' AS DATE))"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (2, CAST('2020-02-02 00:00:00' AS DATE))"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (2, CAST('2020-02-02 00:00:00' AS DATE))"#
);

assert!(
    Query::insert()
        .into_table("glyph")
        .columns(["aspect", "image"])
        .values([1.into()])
        .is_err()
);
Source

pub fn values_panic<I>(&mut self, values: I) -> &mut Self
where I: IntoIterator<Item = Expr>,

Specify a row of values to be inserted, variation of InsertStatement::values.

§Panics

Panics when number of values not matching number of columns. The engine’s insert_many does not panic: it builds the column list from the active models.

§Examples
use sql_builder::*;

let query = Query::insert()
    .into_table("glyph")
    .columns(["aspect", "image"])
    .values_panic([2.1345.into(), "24B".into()])
    .values_panic([5.15.into(), "12A".into()])
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"INSERT INTO `glyph` (`aspect`, `image`) VALUES (2.1345, '24B'), (5.15, '12A')"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (2.1345, '24B'), (5.15, '12A')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (2.1345, '24B'), (5.15, '12A')"#
);
ⓘ
let query = Query::insert()
    .into_table("glyph")
    .columns(["aspect"])
    .values_panic([2.1345.into(), "24B".into()])
    .take();
Source

pub fn values_from_panic<I, J>(&mut self, values_iter: J) -> &mut Self
where I: IntoIterator<Item = Expr>, J: IntoIterator<Item = I>,

Add rows to be inserted from an iterator, variation of InsertStatement::values_panic.

§Examples
use sql_builder::*;

let rows = vec![[2.1345.into(), "24B".into()], [5.15.into(), "12A".into()]];

let query = Query::insert()
    .into_table("glyph")
    .columns(["aspect", "image"])
    .values_from_panic(rows)
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder).unwrap(),
    r#"INSERT INTO `glyph` (`aspect`, `image`) VALUES (2.1345, '24B'), (5.15, '12A')"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (2.1345, '24B'), (5.15, '12A')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder).unwrap(),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (2.1345, '24B'), (5.15, '12A')"#
);

Trait Implementations§

Source§

impl Clone for InsertStatement

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for InsertStatement

Source§

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

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

impl Default for InsertStatement

Source§

fn default() -> Self

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

impl From<InsertStatement> for Expr

Source§

fn from(v: InsertStatement) -> Self

Converts to this type from the input type.
Source§

impl From<InsertStatement> for QueryStatement

Source§

fn from(s: InsertStatement) -> Self

Converts to this type from the input type.
Source§

impl From<InsertStatement> for SubQueryStatement

Source§

fn from(s: InsertStatement) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for InsertStatement

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl QueryStatementBuilder for InsertStatement

Source§

fn build_collect_any_into( &self, query_builder: &impl QueryBuilder, sql: &mut impl SqlWriter, ) -> Result<(), RenderError>

Renders into sql, stopping at the first part that cannot be rendered.
Source§

fn build_any( &self, query_builder: &impl QueryBuilder, ) -> Result<(String, Values), RenderError>

Build corresponding SQL statement for certain database backend and collect query parameters into a vector
Source§

fn build_collect_any( &self, query_builder: &impl QueryBuilder, sql: &mut impl SqlWriter, ) -> Result<String, RenderError>

Build corresponding SQL statement for certain database backend and collect query parameters
Source§

fn into_sub_query_statement(self) -> SubQueryStatement

Source§

impl QueryStatementWriter for InsertStatement

Source§

fn to_string<T: QueryBuilder>( &self, query_builder: T, ) -> Result<String, RenderError>

Build corresponding SQL statement for certain database backend and return SQL string Read more
Source§

fn build<T: QueryBuilder>( &self, query_builder: T, ) -> Result<(String, Values), RenderError>

Build corresponding SQL statement for certain database backend and collect query parameters into a vector Read more
Source§

fn build_collect<T: QueryBuilder>( &self, query_builder: T, sql: &mut impl SqlWriter, ) -> Result<String, RenderError>

Build corresponding SQL statement for certain database backend and collect query parameters Read more
Source§

fn build_collect_into<T: QueryBuilder>( &self, query_builder: T, sql: &mut impl SqlWriter, ) -> Result<(), RenderError>

Renders into sql, stopping at the first part that cannot be rendered.
Source§

impl StructuralPartialEq for InsertStatement

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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

impl<T> 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
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> 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§

fn eq_any<V, I>(self, v: I) -> Expr
where V: Into<Value> + ValueType, I: IntoIterator<Item = V>,

Equivalent to is_in but bind parameters as array. Read more
Source§

fn ne_all<V, I>(self, v: I) -> Expr
where V: Into<Value> + ValueType, I: IntoIterator<Item = V>,

Equivalent to is_not_in but bind parameters as array. Read more
Source§

impl<T> SelectExprTrait for T
where T: Into<Expr>,

Source§

fn alias<A>(self, alias: A) -> SelectExpr
where A: IntoIden,

Source§

fn over(self, over_expr: impl Into<WindowSelectType>) -> SelectExpr

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
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = !

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.