InsertStatement

Struct InsertStatement 

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

Insert any new rows into an existing table

ยงExamples

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

let query = Query::insert()
    .into_table(Glyph::Table)
    .columns([Glyph::Aspect, Glyph::Image])
    .values_panic([5.15.into(), "12A".into()])
    .values_panic([4.21.into(), "123".into()])
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"INSERT INTO `glyph` (`aspect`, `image`) VALUES (5.15, '12A'), (4.21, '123')"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (5.15, '12A'), (4.21, '123')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (5.15, '12A'), (4.21, '123')"#
);
assert_eq!(
    query.audit().unwrap().inserted_tables(),
    [Glyph::Table.into_iden()]
);

Implementationsยง

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

Available on crate features backend-sqlite or backend-mysql only.

Use REPLACE instead of INSERT

ยงExamples
use sea_query::{tests_cfg::*, *};

let query = Query::insert()
    .replace()
    .into_table(Glyph::Table)
    .columns([Glyph::Aspect, Glyph::Image])
    .values_panic([5.15.into(), "12A".into()])
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"REPLACE INTO `glyph` (`aspect`, `image`) VALUES (5.15, '12A')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    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 sea_query::{audit::*, tests_cfg::*, *};

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

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"INSERT INTO `glyph` (`aspect`, `image`) SELECT `aspect`, `image` FROM `glyph` WHERE `image` LIKE '0%'"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"INSERT INTO "glyph" ("aspect", "image") SELECT "aspect", "image" FROM "glyph" WHERE "image" LIKE '0%'"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"INSERT INTO "glyph" ("aspect", "image") SELECT "aspect", "image" FROM "glyph" WHERE "image" LIKE '0%'"#
);
assert_eq!(
    query.audit().unwrap().selected_tables(),
    [Glyph::Table.into_iden()]
);
assert_eq!(
    query.audit().unwrap().inserted_tables(),
    [Glyph::Table.into_iden()]
);
use sea_query::{tests_cfg::*, *};
let query = Query::insert()
    .into_table(Glyph::Table)
    .columns([Glyph::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),
    r#"INSERT INTO "glyph" ("image") SELECT 'hello' WHERE NOT EXISTS(SELECT 'world')"#
);
use sea_query::{audit::*, tests_cfg::*, *};
let query = Query::insert()
    .into_table(Glyph::Table)
    .columns([Glyph::Image])
    .select_from(
        Query::select()
            .expr(Expr::col(Font::Name))
            .from(Font::Table)
            .take(),
    )
    .unwrap()
    .take();

assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"INSERT INTO "glyph" ("image") SELECT "name" FROM "font""#
);
assert_eq!(
    query.audit().unwrap().selected_tables(),
    [Font::Table.into_iden()]
);
assert_eq!(
    query.audit().unwrap().inserted_tables(),
    [Glyph::Table.into_iden()]
);
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 sea_query::{tests_cfg::*, *};

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

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

assert!(
    Query::insert()
        .into_table(Glyph::Table)
        .columns([Glyph::Aspect, Glyph::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.

ยงExamples
use sea_query::{tests_cfg::*, *};

let query = Query::insert()
    .into_table(Glyph::Table)
    .columns([Glyph::Aspect, Glyph::Image])
    .values_panic([2.1345.into(), "24B".into()])
    .values_panic([5.15.into(), "12A".into()])
    .take();

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

The same query can be constructed using the raw_query! macro.

use sea_query::Values;

let values = vec![(2.1345, "24B"), (5.15, "12A")];
let query = sea_query::raw_query!(
    PostgresQueryBuilder,
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES {..(values.0:1),}"#
);

assert_eq!(
    query.sql,
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES ($1, $2), ($3, $4)"#
);
assert_eq!(
    query.values,
    Values(vec![2.1345.into(), "24B".into(), 5.15.into(), "12A".into()])
);

// same as above but with named fields:

struct Item<'a> {
    aspect: f64,
    image: &'a str,
};

let values = vec![
    Item {
        aspect: 2.1345,
        image: "24B",
    },
    Item {
        aspect: 5.15,
        image: "12A",
    },
];

let new_query = sea_query::raw_query!(
    PostgresQueryBuilder,
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES {..(values.aspect, values.image),}"#
);

assert_eq!(query.sql, new_query.sql);
assert_eq!(query.values, new_query.values);
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 sea_query::{audit::*, tests_cfg::*, *};

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

let query = Query::insert()
    .into_table(Glyph::Table)
    .columns([Glyph::Aspect, Glyph::Image])
    .values_from_panic(rows)
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"INSERT INTO `glyph` (`aspect`, `image`) VALUES (2.1345, '24B'), (5.15, '12A')"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (2.1345, '24B'), (5.15, '12A')"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"INSERT INTO "glyph" ("aspect", "image") VALUES (2.1345, '24B'), (5.15, '12A')"#
);
assert_eq!(
    query.audit().unwrap().inserted_tables(),
    [Glyph::Table.into_iden()]
);
Source

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

ON CONFLICT expression

ยงExamples
  • OnConflict::update_columns: Update column value of existing row with inserting value
  • [OnConflict::update_values]: Update column value of existing row with value
  • [OnConflict::update_exprs]: Update column value of existing row with expression
Source

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

RETURNING expressions.

ยงExamples
use sea_query::{tests_cfg::*, *};

let query = Query::insert()
    .into_table(Glyph::Table)
    .columns([Glyph::Image])
    .values_panic(["12A".into()])
    .returning(Query::returning().columns([Glyph::Id]))
    .take();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    "INSERT INTO `glyph` (`image`) VALUES ('12A')"
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"INSERT INTO "glyph" ("image") VALUES ('12A') RETURNING "id""#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    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 sea_query::{tests_cfg::*, *};

let query = Query::insert()
    .into_table(Glyph::Table)
    .columns([Glyph::Image])
    .values_panic(["12A".into()])
    .returning_col(Glyph::Id)
    .take();

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

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

RETURNING expressions all columns.

ยงExamples
use sea_query::{tests_cfg::*, *};

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

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    "INSERT INTO `glyph` (`image`) VALUES ('12A')"
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"INSERT INTO "glyph" ("image") VALUES ('12A') RETURNING *"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    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 sea_query::{*, IntoCondition, IntoIden, tests_cfg::*};

let select = SelectStatement::new()
        .columns([Glyph::Id, Glyph::Image, Glyph::Aspect])
        .from(Glyph::Table)
        .take();
    let cte = CommonTableExpression::new()
        .query(select)
        .column(Glyph::Id)
        .column(Glyph::Image)
        .column(Glyph::Aspect)
        .table_name("cte")
        .to_owned();
    let with_clause = WithClause::new().cte(cte).to_owned();
    let select = SelectStatement::new()
        .columns([Glyph::Id, Glyph::Image, Glyph::Aspect])
        .from("cte")
        .take();
    let mut insert = Query::insert();
    insert
        .into_table(Glyph::Table)
        .columns([Glyph::Id, Glyph::Image, Glyph::Aspect])
        .select_from(select)
        .unwrap();
    let query = insert.with(with_clause);

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    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),
    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),
    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 sea_query::{*, IntoCondition, IntoIden, tests_cfg::*};

let select = SelectStatement::new()
        .columns([Glyph::Id, Glyph::Image, Glyph::Aspect])
        .from(Glyph::Table)
        .take();
    let cte = CommonTableExpression::new()
        .query(select)
        .column(Glyph::Id)
        .column(Glyph::Image)
        .column(Glyph::Aspect)
        .table_name("cte")
        .to_owned();
    let with_clause = WithClause::new().cte(cte).to_owned();
    let select = SelectStatement::new()
        .columns([Glyph::Id, Glyph::Image, Glyph::Aspect])
        .from("cte")
        .take();
    let mut query = Query::insert();
    query
        .with_cte(with_clause)
        .into_table(Glyph::Table)
        .columns([Glyph::Id, Glyph::Image, Glyph::Aspect])
        .select_from(select)
        .unwrap();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    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),
    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),
    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 sea_query::{tests_cfg::*, *};

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

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

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

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

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

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

ยงExamples
use sea_query::{tests_cfg::*, *};

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

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

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

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

impl InsertStatement

Source

pub fn build_collect_any_into( &self, query_builder: &impl QueryBuilder, sql: &mut impl SqlWriter, )

Source

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

Source

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

Sourceยง

impl InsertStatement

Source

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

Source

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

Source

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

Source

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

Trait Implementationsยง

Sourceยง

impl AuditTrait for InsertStatement

Available on crate feature audit only.
Sourceยง

fn audit(&self) -> Result<QueryAccessAudit, Error>

Sourceยง

fn audit_unwrap(&self) -> QueryAccessAudit

Shorthand for audit().unwrap()
Sourceยง

impl Clone for InsertStatement

Sourceยง

fn clone(&self) -> InsertStatement

Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยง

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

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for 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() -> InsertStatement

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: &InsertStatement) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

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 QueryStatementBuilder for InsertStatement

Sourceยง

fn build_collect_any_into( &self, query_builder: &impl QueryBuilder, sql: &mut impl SqlWriter, )

Build corresponding SQL statement into the SqlWriter for certain database backend and collect query parameters
Sourceยง

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

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, ) -> String

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 build_collect_into<T: QueryBuilder>( &self, query_builder: T, sql: &mut impl SqlWriter, )

Sourceยง

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

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

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

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, ) -> String

Build corresponding SQL statement for certain database backend and collect query parameters Read more
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 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>,

Available on crate feature backend-postgres only.
Express an postgres concatenate (||) expression. Read more
Sourceยง

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

Available on crate feature backend-postgres only.
Sourceยง

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

Available on crate feature backend-postgres only.
Express an postgres fulltext search matches (@@) expression. Read more
Sourceยง

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

Available on crate feature backend-postgres only.
Express an postgres fulltext search contains (@>) expression. Read more
Sourceยง

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

Available on crate feature backend-postgres only.
Express an postgres fulltext search contained (<@) expression. Read more
Sourceยง

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

Available on crate feature backend-postgres only.
Express a ILIKE expression. Read more
Sourceยง

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

Available on crate feature backend-postgres only.
Express a NOT ILIKE expression
Sourceยง

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

Available on crate feature backend-postgres only.
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>,

Available on crate feature backend-postgres only.
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>,

Available on crate feature backend-sqlite only.
Express an sqlite GLOB operator. Read more
Sourceยง

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

Available on crate feature backend-sqlite only.
Express an sqlite MATCH operator. Read more
Sourceยง

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

Available on crate feature backend-sqlite only.
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>,

Available on crate feature backend-sqlite only.
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 = Infallible

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

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

Performs the conversion.
Sourceยง

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

Sourceยง

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

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

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

Performs the conversion.