pub struct QueryBuilder<'a, Schema = (), State = (), Table = (), Marker = (), Row = (), Grouped = ()> { /* private fields */ }Expand description
Type-safe SQL query builder for MySQL.
Start with QueryBuilder::new, then call select,
insert, update,
delete or with. Each method returns a
builder in a new state that only offers the clauses that may come next,
so an out-of-order query does not compile. Call ToSQL::to_sql for the
SQL text and parameters, or prepare() for a statement with
placeholders. It does not run queries; the drizzle crate’s MySQL
drivers do.
§Type parameters
Schema: the schema the query runs against.State: which clauses have been added so far.Table: the table the last FROM or JOIN added, or the target table of an INSERT, UPDATE or DELETE.Marker: the selected columns and the tables in scope.Row: the Rust type of one result row.Grouped: the GROUP BY columns.
§Examples
use drizzle::core::expr::eq;
use drizzle::mysql::{builder::QueryBuilder, prelude::*};
#[MySQLTable(NAME = "users")]
struct Users {
#[column(PRIMARY, AUTO_INCREMENT)]
id: u64,
#[column(VARCHAR(255))]
name: String,
#[column(DEFAULT = true)]
active: bool,
}
#[derive(MySQLSchema)]
struct Schema {
users: Users,
}
let builder = QueryBuilder::new::<Schema>();
let Schema { users } = Schema::new();
let query = builder
.select(users.name)
.from(users)
.r#where(eq(users.active, true))
.order_by(asc(users.name))
.limit(10);
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`name` FROM `users` WHERE `users`.`active` = ? ORDER BY `users`.`name` ASC LIMIT ?"
);Implementations§
Source§impl<'a, S, T> QueryBuilder<'a, S, DeleteInitial, T>
impl<'a, S, T> QueryBuilder<'a, S, DeleteInitial, T>
Sourcepub fn where<E, ScopeProof>(
self,
condition: E,
) -> DeleteBuilder<'a, S, DeleteWhereSet, T>where
E: ExprSources + Expr<'a, MySQLValue<'a>>,
E::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
E::SQLType: BooleanLike,
pub fn where<E, ScopeProof>(
self,
condition: E,
) -> DeleteBuilder<'a, S, DeleteWhereSet, T>where
E: ExprSources + Expr<'a, MySQLValue<'a>>,
E::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
E::SQLType: BooleanLike,
Adds a WHERE clause that picks the rows to delete.
The condition must be a boolean expression over the target table’s columns.
Source§impl<'a, S, T, M, R> QueryBuilder<'a, S, DeleteWhereSet, T, M, R>
impl<'a, S, T, M, R> QueryBuilder<'a, S, DeleteWhereSet, T, M, R>
Sourcepub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
pub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
Renders this statement as a PreparedStatement
whose placeholders are bound in MySQL’s positional order.
Source§impl<'a, S, T, M, R> QueryBuilder<'a, S, DeleteOrderSet, T, M, R>
impl<'a, S, T, M, R> QueryBuilder<'a, S, DeleteOrderSet, T, M, R>
Sourcepub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
pub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
Renders this statement as a PreparedStatement
whose placeholders are bound in MySQL’s positional order.
Source§impl<'a, S, T, M, R> QueryBuilder<'a, S, DeleteLimitSet, T, M, R>
impl<'a, S, T, M, R> QueryBuilder<'a, S, DeleteLimitSet, T, M, R>
Sourcepub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
pub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
Renders this statement as a PreparedStatement
whose placeholders are bound in MySQL’s positional order.
Source§impl<'a, S, T> QueryBuilder<'a, S, DeleteWhereSet, T>
impl<'a, S, T> QueryBuilder<'a, S, DeleteWhereSet, T>
Sourcepub fn order_by<O, ScopeProof>(
self,
order: O,
) -> DeleteBuilder<'a, S, DeleteOrderSet, T>
pub fn order_by<O, ScopeProof>( self, order: O, ) -> DeleteBuilder<'a, S, DeleteOrderSet, T>
Adds ORDER BY, which sets the order rows are changed in.
Mostly useful with limit. Only columns of the target
table may be used.
Source§impl<'a, S, T> QueryBuilder<'a, S, DeleteWhereSet, T>
impl<'a, S, T> QueryBuilder<'a, S, DeleteWhereSet, T>
Sourcepub fn limit<P>(self, limit: P) -> DeleteBuilder<'a, S, DeleteLimitSet, T>where
P: PaginationArg<'a, MySQLValue<'a>>,
pub fn limit<P>(self, limit: P) -> DeleteBuilder<'a, S, DeleteLimitSet, T>where
P: PaginationArg<'a, MySQLValue<'a>>,
Adds LIMIT, which caps how many rows are changed.
§Panics
Panics when a numeric argument is negative or does not
fit in usize.
Source§impl<'a, S, T> QueryBuilder<'a, S, DeleteOrderSet, T>
impl<'a, S, T> QueryBuilder<'a, S, DeleteOrderSet, T>
Sourcepub fn limit<P>(self, limit: P) -> DeleteBuilder<'a, S, DeleteLimitSet, T>where
P: PaginationArg<'a, MySQLValue<'a>>,
pub fn limit<P>(self, limit: P) -> DeleteBuilder<'a, S, DeleteLimitSet, T>where
P: PaginationArg<'a, MySQLValue<'a>>,
Adds LIMIT, which caps how many rows are changed.
§Panics
Panics when a numeric argument is negative or does not
fit in usize.
Source§impl<'a, S, T, M, R> QueryBuilder<'a, S, InsertValuesSet, T, M, R>
impl<'a, S, T, M, R> QueryBuilder<'a, S, InsertValuesSet, T, M, R>
Sourcepub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
pub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
Renders this statement as a PreparedStatement
whose placeholders are bound in MySQL’s positional order.
Sourcepub fn on_duplicate_key_update(
self,
values: T::Update,
) -> InsertBuilder<'a, S, InsertOnDuplicateKeyUpdateSet, T, M, R>where
T: MySQLTable<'a>,
pub fn on_duplicate_key_update(
self,
values: T::Update,
) -> InsertBuilder<'a, S, InsertOnDuplicateKeyUpdateSet, T, M, R>where
T: MySQLTable<'a>,
Adds ON DUPLICATE KEY UPDATE, which updates the existing row when
the new one would duplicate any primary or unique key.
values is the table’s generated update model. MySQL picks the
conflicting key itself, so there is no conflict target.
§Panics
Panics when values sets no column.
Source§impl<'a, S, T, M, R> QueryBuilder<'a, S, InsertOnDuplicateKeyUpdateSet, T, M, R>
impl<'a, S, T, M, R> QueryBuilder<'a, S, InsertOnDuplicateKeyUpdateSet, T, M, R>
Sourcepub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
pub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
Renders this statement as a PreparedStatement
whose placeholders are bound in MySQL’s positional order.
Source§impl<'a, Schema, Table> QueryBuilder<'a, Schema, InsertInitial, Table>where
Table: MySQLTable<'a>,
impl<'a, Schema, Table> QueryBuilder<'a, Schema, InsertInitial, Table>where
Table: MySQLTable<'a>,
Sourcepub fn ignore(self) -> InsertBuilder<'a, Schema, InsertIgnoreSet, Table>
pub fn ignore(self) -> InsertBuilder<'a, Schema, InsertIgnoreSet, Table>
Turns this statement into INSERT IGNORE.
MySQL then skips rows that duplicate a key, and also turns many other
errors (such as out-of-range values) into warnings. Use it only when
that is what you want; for duplicates alone, prefer
on_duplicate_key_update.
§Examples
let query = builder.insert(users).ignore().value(InsertUsers::new("Alice"));
assert_eq!(query.to_sql().sql(), "INSERT IGNORE INTO `users` (`name`) VALUES (?)");Source§impl<'a, Schema, State, Table> QueryBuilder<'a, Schema, State, Table>where
State: InsertRowSourceState,
Table: MySQLTable<'a>,
impl<'a, Schema, State, Table> QueryBuilder<'a, Schema, State, Table>where
State: InsertRowSourceState,
Table: MySQLTable<'a>,
Sourcepub fn columns<Columns>(
self,
columns: Columns,
) -> InsertBuilder<'a, Schema, InsertColumnsSet<Columns::Columns>, Table>where
Columns: InsertTargetColumns<'a, MySQLValue<'a>, Table>,
pub fn columns<Columns>(
self,
columns: Columns,
) -> InsertBuilder<'a, Schema, InsertColumnsSet<Columns::Columns>, Table>where
Columns: InsertTargetColumns<'a, MySQLValue<'a>, Table>,
Lists the target columns for an INSERT ... SELECT.
Pass a tuple of the table’s columns, then call
select. The list must include every
required column (one without a default), and the SELECT must produce
matching types in the same order; both are checked at compile time.
§Examples
let query = builder
.insert(posts)
.columns((posts.user_id, posts.title))
.select(builder.select((users.id, users.name)).from(users));
assert_eq!(
query.to_sql().sql(),
"INSERT INTO `posts` (`user_id`, `title`) SELECT `users`.`id`, `users`.`name` FROM `users`"
);§Panics
Panics when the same target column appears more than once.
Sourcepub fn value<T>(
self,
value: Table::Insert<T>,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>
pub fn value<T>( self, value: Table::Insert<T>, ) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>
Inserts one row. Same as values([value]).
value is the table’s generated insert model (for example
InsertUsers).
Sourcepub fn values<I, T>(
self,
values: I,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
I: IntoIterator<Item = Table::Insert<T>>,
pub fn values<I, T>(
self,
values: I,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
I: IntoIterator<Item = Table::Insert<T>>,
Inserts one or more rows.
Each item is the table’s generated insert model, and all rows share
one model type. A with_* setter given None leaves its column out
of that row, so rows can still set different columns; every row then
lists all of them, with DEFAULT for the ones it leaves out. If no
row sets a column, this renders () VALUES ().
§Examples
let query = builder
.insert(users)
.values([InsertUsers::new("Alice"), InsertUsers::new("Bob")]);
assert_eq!(query.to_sql().sql(), "INSERT INTO `users` (`name`) VALUES (?), (?)");§Panics
Panics when values is empty.
Sourcepub fn select<Q, R, ScopeProof, AggProof>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Table: InsertSelectTable,
Q: IntoSelectQuery<'a, Schema, R>,
Q::Marker: InsertSelectCompatible<'a, MySQLValue<'a>, Table, R> + MarkerScopeValidFor<ScopeProof> + MarkerAggValidFor<Q::Grouped, AggProof>,
pub fn select<Q, R, ScopeProof, AggProof>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Table: InsertSelectTable,
Q: IntoSelectQuery<'a, Schema, R>,
Q::Marker: InsertSelectCompatible<'a, MySQLValue<'a>, Table, R> + MarkerScopeValidFor<ScopeProof> + MarkerAggValidFor<Q::Grouped, AggProof>,
Inserts the rows of a SELECT into every insertable column of the table.
The SELECT must produce one value per insertable column, in table
order, with compatible types and nullability; its column references
and aggregates are checked too. To fill only some columns, call
columns first. A WITH clause belongs to the inner
SELECT, so it renders after INSERT INTO table (...).
Sourcepub fn select_raw<Q>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Q: ToSQL<'a, MySQLValue<'a>>,
pub fn select_raw<Q>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Q: ToSQL<'a, MySQLValue<'a>>,
Appends any SQL as the row source, without a column list.
Nothing is checked: not the column count, types, nullability, column
scope or aggregates. Prefer select.
Source§impl<'a, Schema, Table, Targets> QueryBuilder<'a, Schema, InsertColumnsSet<Targets>, Table>where
Table: MySQLTable<'a>,
impl<'a, Schema, Table, Targets> QueryBuilder<'a, Schema, InsertColumnsSet<Targets>, Table>where
Table: MySQLTable<'a>,
Sourcepub fn select<Q, R, RequiredProof, ScopeProof, AggProof>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Targets: IncludesRequired<Table::RequiredColumns, RequiredProof>,
Table: InsertSelectTable,
Q: IntoSelectQuery<'a, Schema, R>,
Q::Marker: PartialInsertSelectCompatible<'a, MySQLValue<'a>, Targets> + MarkerScopeValidFor<ScopeProof> + MarkerAggValidFor<Q::Grouped, AggProof>,
pub fn select<Q, R, RequiredProof, ScopeProof, AggProof>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Targets: IncludesRequired<Table::RequiredColumns, RequiredProof>,
Table: InsertSelectTable,
Q: IntoSelectQuery<'a, Schema, R>,
Q::Marker: PartialInsertSelectCompatible<'a, MySQLValue<'a>, Targets> + MarkerScopeValidFor<ScopeProof> + MarkerAggValidFor<Q::Grouped, AggProof>,
Inserts the rows of a SELECT into the columns chosen with
columns.
The SELECT must produce one value per chosen column, in the same order, with compatible types and nullability.
Sourcepub fn select_raw<Q, RequiredProof>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Table: InsertSelectTable,
Targets: IncludesRequired<Table::RequiredColumns, RequiredProof>,
Q: ToSQL<'a, MySQLValue<'a>>,
pub fn select_raw<Q, RequiredProof>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Table: InsertSelectTable,
Targets: IncludesRequired<Table::RequiredColumns, RequiredProof>,
Q: ToSQL<'a, MySQLValue<'a>>,
Appends any SQL as the row source for the chosen columns.
Only the column list is checked (it must include every required column). The SQL itself is not checked.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: Prepare,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: Prepare,
Sourcepub fn prepare<ScopeProof, AggProof>(
&self,
) -> PreparedStatement<'a, MySQLValue<'a>>where
M: MarkerScopeValidFor<ScopeProof> + MarkerAggValidFor<G, AggProof>,
pub fn prepare<ScopeProof, AggProof>(
&self,
) -> PreparedStatement<'a, MySQLValue<'a>>where
M: MarkerScopeValidFor<ScopeProof> + MarkerAggValidFor<G, AggProof>,
Renders this query as a PreparedStatement.
MySQL binds parameters by position, so named placeholders are put in
the order they appear in the SQL (a name used twice is bound twice).
Bind values by name later with bind.
§Compile-time checks
Only compiles when every column reference is in scope (its table is in FROM or a JOIN) and every selected column is grouped or inside an aggregate.
§Examples
let query = builder
.select(users.id)
.from(users)
.r#where(eq(users.name, Placeholder::named("name")));
let prepared = query.prepare();
assert_eq!(prepared.sql(), "SELECT `users`.`id` FROM `users` WHERE `users`.`name` = ?");Source§impl<'a, S, M> QueryBuilder<'a, S, SelectInitial, (), M>
impl<'a, S, M> QueryBuilder<'a, S, SelectInitial, (), M>
Sourcepub fn from<T>(
self,
table: T,
) -> SelectBuilder<'a, S, SelectFromSet, T, FromMarker<M, T>, <M as ResolveRow<T>>::Row>
pub fn from<T>( self, table: T, ) -> SelectBuilder<'a, S, SelectFromSet, T, FromMarker<M, T>, <M as ResolveRow<T>>::Row>
Sets the FROM source: a table, a CTE, or a derived table made with
alias.
The result row type is inferred from the selected columns and this
source. With select(()), the row is the table’s generated select
model.
Source§impl<'a, S, T, M, R, G> QueryBuilder<'a, S, SelectFromSet, T, M, R, G>where
T: MySQLTable<'a>,
impl<'a, S, T, M, R, G> QueryBuilder<'a, S, SelectFromSet, T, M, R, G>where
T: MySQLTable<'a>,
Sourcepub fn use_index<Indexes>(
self,
indexes: Indexes,
) -> SelectBuilder<'a, S, SelectIndexHintSet<UseIndex>, T, M, R, G>where
Indexes: IndexHintList<'a, T>,
pub fn use_index<Indexes>(
self,
indexes: Indexes,
) -> SelectBuilder<'a, S, SelectIndexHintSet<UseIndex>, T, M, R, G>where
Indexes: IndexHintList<'a, T>,
Adds USE INDEX (..) to the FROM table.
Pass one #[MySQLIndex] index of this table, or a tuple of up to
eight. An index of another table does not compile. Only one hint
(use_index, force_index or ignore_index) can be added, right
after from. To hint a joined table, use MySQLIndexHintExt.
§Examples
let query = builder
.select(users.id)
.from(users)
.use_index(UsersNameIdx::new());
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`id` FROM `users` USE INDEX (`users_name_idx`)"
);Sourcepub fn force_index<Indexes>(
self,
indexes: Indexes,
) -> SelectBuilder<'a, S, SelectIndexHintSet<ForceIndex>, T, M, R, G>where
Indexes: IndexHintList<'a, T>,
pub fn force_index<Indexes>(
self,
indexes: Indexes,
) -> SelectBuilder<'a, S, SelectIndexHintSet<ForceIndex>, T, M, R, G>where
Indexes: IndexHintList<'a, T>,
Adds FORCE INDEX (..) to the FROM table, which tells MySQL to use
a table scan only if none of these indexes can be used. See
use_index.
Sourcepub fn ignore_index<Indexes>(
self,
indexes: Indexes,
) -> SelectBuilder<'a, S, SelectIndexHintSet<IgnoreIndex>, T, M, R, G>where
Indexes: IndexHintList<'a, T>,
pub fn ignore_index<Indexes>(
self,
indexes: Indexes,
) -> SelectBuilder<'a, S, SelectIndexHintSet<IgnoreIndex>, T, M, R, G>where
Indexes: IndexHintList<'a, T>,
Adds IGNORE INDEX (..) to the FROM table. See
use_index.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Join>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Join>,
Sourcepub fn join<J: JoinArg<'a, T, Via>, Via>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, InnerJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, InnerJoin, J::OnSources>>::Row, G>
pub fn join<J: JoinArg<'a, T, Via>, Via>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, InnerJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, InnerJoin, J::OnSources>>::Row, G>
Adds a join with join.
Pass (source, condition) with a boolean condition, or a bare table
to join on its foreign key to the previous table. The source can be
a table, a derived table (see alias), or a table
with an index hint (see MySQLIndexHintExt).
After a LEFT or RIGHT join, selected columns of the side that may
be missing decode as Option; with select(()), that side’s
whole model is an Option in the row.
§Examples
let query = builder
.select((users.name, posts.title))
.from(users)
.left_join((posts, eq(posts.user_id, users.id)));
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`name`, `posts`.`title` FROM `users` LEFT JOIN `posts` ON `posts`.`user_id` = `users`.`id`"
);Sourcepub fn inner_join<J: JoinArg<'a, T, Via>, Via>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, InnerJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, InnerJoin, J::OnSources>>::Row, G>
pub fn inner_join<J: JoinArg<'a, T, Via>, Via>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, InnerJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, InnerJoin, J::OnSources>>::Row, G>
Adds a join with inner_join.
Pass (source, condition) with a boolean condition, or a bare table
to join on its foreign key to the previous table. The source can be
a table, a derived table (see alias), or a table
with an index hint (see MySQLIndexHintExt).
After a LEFT or RIGHT join, selected columns of the side that may
be missing decode as Option; with select(()), that side’s
whole model is an Option in the row.
§Examples
let query = builder
.select((users.name, posts.title))
.from(users)
.left_join((posts, eq(posts.user_id, users.id)));
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`name`, `posts`.`title` FROM `users` LEFT JOIN `posts` ON `posts`.`user_id` = `users`.`id`"
);Sourcepub fn left_join<J: JoinArg<'a, T, Via>, Via>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, LeftJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, LeftJoin, J::OnSources>>::Row, G>
pub fn left_join<J: JoinArg<'a, T, Via>, Via>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, LeftJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, LeftJoin, J::OnSources>>::Row, G>
Adds a join with left_join.
Pass (source, condition) with a boolean condition, or a bare table
to join on its foreign key to the previous table. The source can be
a table, a derived table (see alias), or a table
with an index hint (see MySQLIndexHintExt).
After a LEFT or RIGHT join, selected columns of the side that may
be missing decode as Option; with select(()), that side’s
whole model is an Option in the row.
§Examples
let query = builder
.select((users.name, posts.title))
.from(users)
.left_join((posts, eq(posts.user_id, users.id)));
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`name`, `posts`.`title` FROM `users` LEFT JOIN `posts` ON `posts`.`user_id` = `users`.`id`"
);Sourcepub fn left_outer_join<J: JoinArg<'a, T, Via>, Via>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, LeftJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, LeftJoin, J::OnSources>>::Row, G>
pub fn left_outer_join<J: JoinArg<'a, T, Via>, Via>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, LeftJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, LeftJoin, J::OnSources>>::Row, G>
Adds a join with left_outer_join.
Pass (source, condition) with a boolean condition, or a bare table
to join on its foreign key to the previous table. The source can be
a table, a derived table (see alias), or a table
with an index hint (see MySQLIndexHintExt).
After a LEFT or RIGHT join, selected columns of the side that may
be missing decode as Option; with select(()), that side’s
whole model is an Option in the row.
§Examples
let query = builder
.select((users.name, posts.title))
.from(users)
.left_join((posts, eq(posts.user_id, users.id)));
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`name`, `posts`.`title` FROM `users` LEFT JOIN `posts` ON `posts`.`user_id` = `users`.`id`"
);Sourcepub fn right_join<J: JoinArg<'a, T, Via>, Via>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, RightJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, RightJoin, J::OnSources>>::Row, G>
pub fn right_join<J: JoinArg<'a, T, Via>, Via>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, RightJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, RightJoin, J::OnSources>>::Row, G>
Adds a join with right_join.
Pass (source, condition) with a boolean condition, or a bare table
to join on its foreign key to the previous table. The source can be
a table, a derived table (see alias), or a table
with an index hint (see MySQLIndexHintExt).
After a LEFT or RIGHT join, selected columns of the side that may
be missing decode as Option; with select(()), that side’s
whole model is an Option in the row.
§Examples
let query = builder
.select((users.name, posts.title))
.from(users)
.left_join((posts, eq(posts.user_id, users.id)));
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`name`, `posts`.`title` FROM `users` LEFT JOIN `posts` ON `posts`.`user_id` = `users`.`id`"
);Sourcepub fn right_outer_join<J: JoinArg<'a, T, Via>, Via>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, RightJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, RightJoin, J::OnSources>>::Row, G>
pub fn right_outer_join<J: JoinArg<'a, T, Via>, Via>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, RightJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, RightJoin, J::OnSources>>::Row, G>
Adds a join with right_outer_join.
Pass (source, condition) with a boolean condition, or a bare table
to join on its foreign key to the previous table. The source can be
a table, a derived table (see alias), or a table
with an index hint (see MySQLIndexHintExt).
After a LEFT or RIGHT join, selected columns of the side that may
be missing decode as Option; with select(()), that side’s
whole model is an Option in the row.
§Examples
let query = builder
.select((users.name, posts.title))
.from(users)
.left_join((posts, eq(posts.user_id, users.id)));
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`name`, `posts`.`title` FROM `users` LEFT JOIN `posts` ON `posts`.`user_id` = `users`.`id`"
);Sourcepub fn cross_join<Arg: CrossJoinArg<'a, T>>(
self,
arg: Arg,
) -> SelectBuilder<'a, S, SelectJoinSet, Arg::JoinedTable, <M as JoinStep<R, Arg::JoinedTable, InnerJoin, Arg::OnSources>>::Marker, <M as JoinStep<R, Arg::JoinedTable, InnerJoin, Arg::OnSources>>::Row, G>
pub fn cross_join<Arg: CrossJoinArg<'a, T>>( self, arg: Arg, ) -> SelectBuilder<'a, S, SelectJoinSet, Arg::JoinedTable, <M as JoinStep<R, Arg::JoinedTable, InnerJoin, Arg::OnSources>>::Marker, <M as JoinStep<R, Arg::JoinedTable, InnerJoin, Arg::OnSources>>::Row, G>
Adds a CROSS JOIN, which pairs every row with every row of arg.
A bare source renders CROSS JOIN. For backwards compatibility,
(source, condition) renders the equivalent INNER JOIN ... ON ....
Sourcepub fn inner_join_lateral<Arg>(
self,
arg: Arg,
) -> SelectBuilder<'a, S, SelectJoinSet, Arg::JoinedTable, <M as JoinStep<R, Arg::JoinedTable, Lateral<InnerJoin>, Arg::OnSources>>::Marker, <M as JoinStep<R, Arg::JoinedTable, Lateral<InnerJoin>, Arg::OnSources>>::Row, G>where
Arg: LateralArg<'a, MySQLValue<'a>>,
M: JoinStep<R, Arg::JoinedTable, Lateral<InnerJoin>, Arg::OnSources>,
pub fn inner_join_lateral<Arg>(
self,
arg: Arg,
) -> SelectBuilder<'a, S, SelectJoinSet, Arg::JoinedTable, <M as JoinStep<R, Arg::JoinedTable, Lateral<InnerJoin>, Arg::OnSources>>::Marker, <M as JoinStep<R, Arg::JoinedTable, Lateral<InnerJoin>, Arg::OnSources>>::Row, G>where
Arg: LateralArg<'a, MySQLValue<'a>>,
M: JoinStep<R, Arg::JoinedTable, Lateral<InnerJoin>, Arg::OnSources>,
Adds INNER JOIN LATERAL (subquery) AS name ON condition.
A lateral subquery may reference columns of the tables before it.
Requires MySQL 8.0.14 or later.
Sourcepub fn left_join_lateral<Arg, SelectionProof>(
self,
arg: Arg,
) -> SelectBuilder<'a, S, SelectJoinSet, Arg::JoinedTable, <M as JoinStep<R, Arg::JoinedTable, Lateral<LeftJoin>, Arg::OnSources>>::Marker, <M as JoinStep<R, Arg::JoinedTable, Lateral<LeftJoin>, Arg::OnSources>>::Row, G>where
Arg: LateralArg<'a, MySQLValue<'a>>,
M: JoinStep<R, Arg::JoinedTable, Lateral<LeftJoin>, Arg::OnSources> + LeftLateralSelection<SelectionProof>,
pub fn left_join_lateral<Arg, SelectionProof>(
self,
arg: Arg,
) -> SelectBuilder<'a, S, SelectJoinSet, Arg::JoinedTable, <M as JoinStep<R, Arg::JoinedTable, Lateral<LeftJoin>, Arg::OnSources>>::Marker, <M as JoinStep<R, Arg::JoinedTable, Lateral<LeftJoin>, Arg::OnSources>>::Row, G>where
Arg: LateralArg<'a, MySQLValue<'a>>,
M: JoinStep<R, Arg::JoinedTable, Lateral<LeftJoin>, Arg::OnSources> + LeftLateralSelection<SelectionProof>,
Adds LEFT JOIN LATERAL (subquery) AS name ON condition.
Like inner_join_lateral, but keeps rows
with no match. The selection must allow the lateral columns to be
missing.
Sourcepub fn cross_join_lateral<Source>(
self,
source: Source,
) -> SelectBuilder<'a, S, SelectJoinSet, Source::JoinedTable, <M as JoinStep<R, Source::JoinedTable, Lateral<InnerJoin>>>::Marker, <M as JoinStep<R, Source::JoinedTable, Lateral<InnerJoin>>>::Row, G>where
Source: LateralSource<'a, MySQLValue<'a>>,
M: JoinStep<R, Source::JoinedTable, Lateral<InnerJoin>>,
pub fn cross_join_lateral<Source>(
self,
source: Source,
) -> SelectBuilder<'a, S, SelectJoinSet, Source::JoinedTable, <M as JoinStep<R, Source::JoinedTable, Lateral<InnerJoin>>>::Marker, <M as JoinStep<R, Source::JoinedTable, Lateral<InnerJoin>>>::Row, G>where
Source: LateralSource<'a, MySQLValue<'a>>,
M: JoinStep<R, Source::JoinedTable, Lateral<InnerJoin>>,
Adds CROSS JOIN LATERAL (subquery) AS name, with no ON condition.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: SelectClause<Where>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: SelectClause<Where>,
Sourcepub fn where<E>(
self,
condition: E,
) -> SelectBuilder<'a, S, SelectWhereSet, T, <M as HasScope>::With<E::Sources>, R, G>
pub fn where<E>( self, condition: E, ) -> SelectBuilder<'a, S, SelectWhereSet, T, <M as HasScope>::With<E::Sources>, R, G>
Adds a WHERE clause. The condition must be a boolean expression.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<GroupBy>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<GroupBy>,
Sourcepub fn group_by<Gr>(
self,
columns: Gr,
) -> SelectBuilder<'a, S, SelectGroupSet, T, <M as HasScope>::With<Gr::Sources>, R, Gr::Columns>
pub fn group_by<Gr>( self, columns: Gr, ) -> SelectBuilder<'a, S, SelectGroupSet, T, <M as HasScope>::With<Gr::Sources>, R, Gr::Columns>
Adds a GROUP BY clause. Pass one expression or a tuple.
Every selected column that is not inside an aggregate must appear in
the GROUP BY list, or belong to a table grouped by its single-column
primary key. This is checked by prepare and when the query runs.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Having>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Having>,
Sourcepub fn having<E>(
self,
condition: E,
) -> SelectBuilder<'a, S, SelectHavingSet, T, <M as HasScope>::With<E::Sources>, R, G>
pub fn having<E>( self, condition: E, ) -> SelectBuilder<'a, S, SelectHavingSet, T, <M as HasScope>::With<E::Sources>, R, G>
Adds a HAVING clause, which filters groups.
Only available after group_by, and only once. The condition must
be a boolean expression and may use aggregates.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: SelectClause<OrderBy>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: SelectClause<OrderBy>,
Sourcepub fn order_by<O>(
self,
order: O,
) -> SelectBuilder<'a, S, SelectOrderSet, T, <M as HasScope>::With<O::Sources>, R, G>
pub fn order_by<O>( self, order: O, ) -> SelectBuilder<'a, S, SelectOrderSet, T, <M as HasScope>::With<O::Sources>, R, G>
Source§impl<'a, S, T, M, R, G> QueryBuilder<'a, S, SelectSetOpSet, T, M, R, G>
impl<'a, S, T, M, R, G> QueryBuilder<'a, S, SelectSetOpSet, T, M, R, G>
Sourcepub fn order_by<O, Proof>(
self,
order: O,
) -> SelectBuilder<'a, S, SelectOrderSet, T, M, R, G>where
O: SetOrderBy<'a, M, T, Proof>,
pub fn order_by<O, Proof>(
self,
order: O,
) -> SelectBuilder<'a, S, SelectOrderSet, T, M, R, G>where
O: SetOrderBy<'a, M, T, Proof>,
Sorts a compound (set operation) result.
Pass a selected column (rendered without its table name), or
output_alias for a named output,
optionally wrapped in asc or
desc. A column the first query does not
select does not compile.
§Examples
let query = builder
.select(alias(users.name, "label"))
.from(users)
.union(builder.select(alias(posts.title, "label")).from(posts))
.order_by(desc(output_alias("label")));
assert_eq!(
query.to_sql().sql(),
"(SELECT `users`.`name` AS `label` FROM `users`) UNION (SELECT `posts`.`title` AS `label` FROM `posts`) ORDER BY `label` DESC"
);Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: SelectClause<Limit>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: SelectClause<Limit>,
Sourcepub fn limit<P>(
self,
limit: P,
) -> SelectBuilder<'a, S, SelectLimitSet, T, M, R, G>where
P: PaginationArg<'a, MySQLValue<'a>>,
pub fn limit<P>(
self,
limit: P,
) -> SelectBuilder<'a, S, SelectLimitSet, T, M, R, G>where
P: PaginationArg<'a, MySQLValue<'a>>,
Adds a LIMIT clause.
Pass a non-negative integer or an integer placeholder. Both are sent as bound parameters.
§Panics
Panics when a numeric argument is negative or does not fit in
usize.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<MySqlOffset>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<MySqlOffset>,
Sourcepub fn offset<P>(
self,
offset: P,
) -> SelectBuilder<'a, S, SelectOffsetSet, T, M, R, G>where
P: PaginationArg<'a, MySQLValue<'a>>,
pub fn offset<P>(
self,
offset: P,
) -> SelectBuilder<'a, S, SelectOffsetSet, T, M, R, G>where
P: PaginationArg<'a, MySQLValue<'a>>,
Skips the first offset rows without limiting the row count.
MySQL has no bare OFFSET, so this renders
LIMIT 9223372036854775807 OFFSET ? (see
[drizzle_core::helpers::MYSQL_UNBOUNDED_LIMIT]).
§Examples
let query = builder.select(users.id).from(users).offset(5);
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`id` FROM `users` LIMIT 9223372036854775807 OFFSET ?"
);§Panics
Panics when a numeric argument is negative or does not fit in
usize.
Source§impl<'a, S, T, M, R, G> QueryBuilder<'a, S, SelectLimitSet, T, M, R, G>
impl<'a, S, T, M, R, G> QueryBuilder<'a, S, SelectLimitSet, T, M, R, G>
Sourcepub fn offset<P>(
self,
offset: P,
) -> SelectBuilder<'a, S, SelectOffsetSet, T, M, R, G>where
P: PaginationArg<'a, MySQLValue<'a>>,
pub fn offset<P>(
self,
offset: P,
) -> SelectBuilder<'a, S, SelectOffsetSet, T, M, R, G>where
P: PaginationArg<'a, MySQLValue<'a>>,
Adds an OFFSET clause after LIMIT.
§Panics
Panics when a numeric argument is negative or does not fit in
usize.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Simple>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Simple>,
Sourcepub fn for_update(
self,
) -> SelectBuilder<'a, S, SelectForSet<ForUpdate>, T, M, R, G>
pub fn for_update( self, ) -> SelectBuilder<'a, S, SelectForSet<ForUpdate>, T, M, R, G>
Adds FOR UPDATE, which locks the selected rows until the
transaction ends.
Must be the last clause; only nowait or
skip_locked can follow. Not available on a
compound query, and the result cannot be a set operand, a subquery or
an INSERT source.
§Examples
let query = builder
.select(users.id)
.from(users)
.limit(2)
.for_update()
.skip_locked();
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`id` FROM `users` LIMIT ? FOR UPDATE SKIP LOCKED"
);Adds FOR SHARE, which takes shared locks on the selected rows: other
transactions can read them but not change them. See
for_update.
Source§impl<'a, S, Strength, T, M, R, G> QueryBuilder<'a, S, SelectForSet<Strength>, T, M, R, G>
impl<'a, S, Strength, T, M, R, G> QueryBuilder<'a, S, SelectForSet<Strength>, T, M, R, G>
Sourcepub fn nowait(
self,
) -> SelectBuilder<'a, S, SelectForSet<Strength, NoWait>, T, M, R, G>
pub fn nowait( self, ) -> SelectBuilder<'a, S, SelectForSet<Strength, NoWait>, T, M, R, G>
Adds NOWAIT: fail at once instead of waiting when a row is locked
by another transaction.
Sourcepub fn skip_locked(
self,
) -> SelectBuilder<'a, S, SelectForSet<Strength, SkipLocked>, T, M, R, G>
pub fn skip_locked( self, ) -> SelectBuilder<'a, S, SelectForSet<Strength, SkipLocked>, T, M, R, G>
Adds SKIP LOCKED: leave out rows locked by another transaction
instead of waiting for them.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Simple> + ExecutableState,
T: SQLTable<'a, MySQLSchemaType, MySQLValue<'a>>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Simple> + ExecutableState,
T: SQLTable<'a, MySQLSchemaType, MySQLValue<'a>>,
Sourcepub fn into_cte<Tag: Tag + 'static>(
self,
) -> CTEView<'a, <T as SQLTable<'a, MySQLSchemaType, MySQLValue<'a>>>::Aliased<Tag>, Self>
pub fn into_cte<Tag: Tag + 'static>( self, ) -> CTEView<'a, <T as SQLTable<'a, MySQLSchemaType, MySQLValue<'a>>>::Aliased<Tag>, Self>
Turns this SELECT into a common table expression named Tag::NAME.
The result derefs to an aliased copy of the FROM table, so you can
select its columns with the usual field access. Pass it to
QueryBuilder::with, which has an
example. Not available on a compound query.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Source>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Source>,
Sourcepub fn alias<Tag, AggProof>(
self,
_tag: Tag,
) -> Derived<'a, MySQLValue<'a>, Tag, <M as DerivedSelection<'a, MySQLValue<'a>, MySQLSchemaType, T>>::Projection, Self>where
Tag: Tag,
M: DerivedSelection<'a, MySQLValue<'a>, MySQLSchemaType, T> + MarkerAggValidFor<G, AggProof>,
<M as DerivedSelection<'a, MySQLValue<'a>, MySQLSchemaType, T>>::Projection: DerivedProjection<Tag>,
pub fn alias<Tag, AggProof>(
self,
_tag: Tag,
) -> Derived<'a, MySQLValue<'a>, Tag, <M as DerivedSelection<'a, MySQLValue<'a>, MySQLSchemaType, T>>::Projection, Self>where
Tag: Tag,
M: DerivedSelection<'a, MySQLValue<'a>, MySQLSchemaType, T> + MarkerAggValidFor<G, AggProof>,
<M as DerivedSelection<'a, MySQLValue<'a>, MySQLSchemaType, T>>::Projection: DerivedProjection<Tag>,
Names this query so it can be used as a derived table in from or a
join.
tag is a value of a Tag type; its NAME
becomes the SQL alias. The result exposes the selected columns, so
the outer query can reference them with typed accessors.
§Panics
Panics when the projection contains duplicate output names. Name a
computed expression with drizzle_core::expr::AliasExt::named to
make each output unique.
Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Compound>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Compound>,
Sourcepub fn union<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
pub fn union<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
Combines this query with other using union.
Both queries must select the same row type. Each operand is wrapped
in parentheses, so its own ORDER BY and LIMIT stay with it. After a
set operation you can chain more set operations, then order_by,
limit and offset for the combined result. INTERSECT and
EXCEPT need MySQL 8.0.31 or later.
§Examples
let query = builder
.select(users.id)
.from(users)
.union(builder.select(posts.user_id).from(posts));
assert_eq!(
query.to_sql().sql(),
"(SELECT `users`.`id` FROM `users`) UNION (SELECT `posts`.`user_id` FROM `posts`)"
);Sourcepub fn union_all<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
pub fn union_all<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
Combines this query with other using union_all.
Both queries must select the same row type. Each operand is wrapped
in parentheses, so its own ORDER BY and LIMIT stay with it. After a
set operation you can chain more set operations, then order_by,
limit and offset for the combined result. INTERSECT and
EXCEPT need MySQL 8.0.31 or later.
§Examples
let query = builder
.select(users.id)
.from(users)
.union(builder.select(posts.user_id).from(posts));
assert_eq!(
query.to_sql().sql(),
"(SELECT `users`.`id` FROM `users`) UNION (SELECT `posts`.`user_id` FROM `posts`)"
);Sourcepub fn intersect<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
pub fn intersect<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
Combines this query with other using intersect.
Both queries must select the same row type. Each operand is wrapped
in parentheses, so its own ORDER BY and LIMIT stay with it. After a
set operation you can chain more set operations, then order_by,
limit and offset for the combined result. INTERSECT and
EXCEPT need MySQL 8.0.31 or later.
§Examples
let query = builder
.select(users.id)
.from(users)
.union(builder.select(posts.user_id).from(posts));
assert_eq!(
query.to_sql().sql(),
"(SELECT `users`.`id` FROM `users`) UNION (SELECT `posts`.`user_id` FROM `posts`)"
);Sourcepub fn intersect_all<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
pub fn intersect_all<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
Combines this query with other using intersect_all.
Both queries must select the same row type. Each operand is wrapped
in parentheses, so its own ORDER BY and LIMIT stay with it. After a
set operation you can chain more set operations, then order_by,
limit and offset for the combined result. INTERSECT and
EXCEPT need MySQL 8.0.31 or later.
§Examples
let query = builder
.select(users.id)
.from(users)
.union(builder.select(posts.user_id).from(posts));
assert_eq!(
query.to_sql().sql(),
"(SELECT `users`.`id` FROM `users`) UNION (SELECT `posts`.`user_id` FROM `posts`)"
);Sourcepub fn except<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
pub fn except<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
Combines this query with other using except.
Both queries must select the same row type. Each operand is wrapped
in parentheses, so its own ORDER BY and LIMIT stay with it. After a
set operation you can chain more set operations, then order_by,
limit and offset for the combined result. INTERSECT and
EXCEPT need MySQL 8.0.31 or later.
§Examples
let query = builder
.select(users.id)
.from(users)
.union(builder.select(posts.user_id).from(posts));
assert_eq!(
query.to_sql().sql(),
"(SELECT `users`.`id` FROM `users`) UNION (SELECT `posts`.`user_id` FROM `posts`)"
);Sourcepub fn except_all<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
pub fn except_all<O>(
self,
other: O,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<O::Marker>>::Combined, R, G>where
O: IntoSelectQuery<'a, S, R>,
M: SetOperand<O::Marker>,
Combines this query with other using except_all.
Both queries must select the same row type. Each operand is wrapped
in parentheses, so its own ORDER BY and LIMIT stay with it. After a
set operation you can chain more set operations, then order_by,
limit and offset for the combined result. INTERSECT and
EXCEPT need MySQL 8.0.31 or later.
§Examples
let query = builder
.select(users.id)
.from(users)
.union(builder.select(posts.user_id).from(posts));
assert_eq!(
query.to_sql().sql(),
"(SELECT `users`.`id` FROM `users`) UNION (SELECT `posts`.`user_id` FROM `posts`)"
);Source§impl<'a, Schema, Table> QueryBuilder<'a, Schema, UpdateInitial, Table>
impl<'a, Schema, Table> QueryBuilder<'a, Schema, UpdateInitial, Table>
Sourcepub fn set(
self,
values: Table::Update,
) -> UpdateBuilder<'a, Schema, UpdateSetClauseSet, Table>
pub fn set( self, values: Table::Update, ) -> UpdateBuilder<'a, Schema, UpdateSetClauseSet, Table>
Sets the columns to change, using the table’s generated update model.
Start from UpdateX::default() and call a with_* setter for each
column to change. Columns you do not set are left as they are.
Source§impl<'a, S, T> QueryBuilder<'a, S, UpdateSetClauseSet, T>
impl<'a, S, T> QueryBuilder<'a, S, UpdateSetClauseSet, T>
Sourcepub fn where<E, ScopeProof>(
self,
condition: E,
) -> UpdateBuilder<'a, S, UpdateWhereSet, T>where
E: ExprSources + Expr<'a, MySQLValue<'a>>,
E::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
E::SQLType: BooleanLike,
pub fn where<E, ScopeProof>(
self,
condition: E,
) -> UpdateBuilder<'a, S, UpdateWhereSet, T>where
E: ExprSources + Expr<'a, MySQLValue<'a>>,
E::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
E::SQLType: BooleanLike,
Adds a WHERE clause that picks the rows to update.
The condition must be a boolean expression over the updated table’s columns.
Source§impl<'a, S, T, M, R> QueryBuilder<'a, S, UpdateWhereSet, T, M, R>
impl<'a, S, T, M, R> QueryBuilder<'a, S, UpdateWhereSet, T, M, R>
Sourcepub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
pub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
Renders this statement as a PreparedStatement
whose placeholders are bound in MySQL’s positional order.
Source§impl<'a, S, T, M, R> QueryBuilder<'a, S, UpdateOrderSet, T, M, R>
impl<'a, S, T, M, R> QueryBuilder<'a, S, UpdateOrderSet, T, M, R>
Sourcepub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
pub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
Renders this statement as a PreparedStatement
whose placeholders are bound in MySQL’s positional order.
Source§impl<'a, S, T, M, R> QueryBuilder<'a, S, UpdateLimitSet, T, M, R>
impl<'a, S, T, M, R> QueryBuilder<'a, S, UpdateLimitSet, T, M, R>
Sourcepub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
pub fn prepare(&self) -> PreparedStatement<'a, MySQLValue<'a>>
Renders this statement as a PreparedStatement
whose placeholders are bound in MySQL’s positional order.
Source§impl<'a, S, T> QueryBuilder<'a, S, UpdateWhereSet, T>
impl<'a, S, T> QueryBuilder<'a, S, UpdateWhereSet, T>
Sourcepub fn order_by<O, ScopeProof>(
self,
order: O,
) -> UpdateBuilder<'a, S, UpdateOrderSet, T>
pub fn order_by<O, ScopeProof>( self, order: O, ) -> UpdateBuilder<'a, S, UpdateOrderSet, T>
Adds ORDER BY, which sets the order rows are changed in.
Mostly useful with limit. Only columns of the target
table may be used.
Source§impl<'a, S, T> QueryBuilder<'a, S, UpdateWhereSet, T>
impl<'a, S, T> QueryBuilder<'a, S, UpdateWhereSet, T>
Sourcepub fn limit<P>(self, limit: P) -> UpdateBuilder<'a, S, UpdateLimitSet, T>where
P: PaginationArg<'a, MySQLValue<'a>>,
pub fn limit<P>(self, limit: P) -> UpdateBuilder<'a, S, UpdateLimitSet, T>where
P: PaginationArg<'a, MySQLValue<'a>>,
Adds LIMIT, which caps how many rows are changed.
§Panics
Panics when a numeric argument is negative or does not
fit in usize.
Source§impl<'a, S, T> QueryBuilder<'a, S, UpdateOrderSet, T>
impl<'a, S, T> QueryBuilder<'a, S, UpdateOrderSet, T>
Sourcepub fn limit<P>(self, limit: P) -> UpdateBuilder<'a, S, UpdateLimitSet, T>where
P: PaginationArg<'a, MySQLValue<'a>>,
pub fn limit<P>(self, limit: P) -> UpdateBuilder<'a, S, UpdateLimitSet, T>where
P: PaginationArg<'a, MySQLValue<'a>>,
Adds LIMIT, which caps how many rows are changed.
§Panics
Panics when a numeric argument is negative or does not
fit in usize.
Source§impl<'a, Schema, State, Table, Marker, Row, Grouped> QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
State: ExecutableState,
impl<'a, Schema, State, Table, Marker, Row, Grouped> QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
State: ExecutableState,
Sourcepub fn comment(self, text: impl AsRef<str>) -> Self
pub fn comment(self, text: impl AsRef<str>) -> Self
Prepends a sqlcommenter
comment (/*...*/) to the query.
/* and */ inside text are broken up (/ *, * /) so the text
cannot end the comment early. An empty text leaves the query
unchanged.
Prepends a tag-style sqlcommenter comment to the query.
Each (key, value) pair is URL-encoded and written as key='value'.
Pairs are sorted and joined with ,. Pairs with an empty value are
skipped; if none remain, the query is unchanged.
Source§impl<'a> QueryBuilder<'a>
impl<'a> QueryBuilder<'a>
Sourcepub const fn new<S>() -> QueryBuilder<'a, S, BuilderInit>
pub const fn new<S>() -> QueryBuilder<'a, S, BuilderInit>
Creates a query builder for the schema S.
Source§impl<'a, Schema> QueryBuilder<'a, Schema, BuilderInit>
impl<'a, Schema> QueryBuilder<'a, Schema, BuilderInit>
Sourcepub fn select<T>(
&self,
columns: T,
) -> SelectBuilder<'a, Schema, SelectInitial, (), T::Marker>
pub fn select<T>( &self, columns: T, ) -> SelectBuilder<'a, Schema, SelectInitial, (), T::Marker>
Starts a SELECT with the given columns.
Pass one column or expression, a tuple of them, or () to select
every column of the FROM table (and of joined tables). Call
from next.
§Examples
let query = builder.select(()).from(users);
assert_eq!(
query.to_sql().sql(),
"SELECT `users`.`id`, `users`.`name`, `users`.`active` FROM `users`"
);Sourcepub fn select_distinct<T>(
&self,
columns: T,
) -> SelectBuilder<'a, Schema, SelectInitial, (), T::Marker>
pub fn select_distinct<T>( &self, columns: T, ) -> SelectBuilder<'a, Schema, SelectInitial, (), T::Marker>
Starts a SELECT DISTINCT, which drops duplicate rows.
Sourcepub fn insert<Table>(
&self,
table: Table,
) -> InsertBuilder<'a, Schema, InsertInitial, Table>where
Table: MySQLTable<'a>,
pub fn insert<Table>(
&self,
table: Table,
) -> InsertBuilder<'a, Schema, InsertInitial, Table>where
Table: MySQLTable<'a>,
Sourcepub fn update<Table>(
&self,
table: Table,
) -> UpdateBuilder<'a, Schema, UpdateInitial, Table>where
Table: MySQLTable<'a>,
pub fn update<Table>(
&self,
table: Table,
) -> UpdateBuilder<'a, Schema, UpdateInitial, Table>where
Table: MySQLTable<'a>,
Starts an UPDATE of table. Call
set next.
Sourcepub fn delete<Table>(
&self,
table: Table,
) -> DeleteBuilder<'a, Schema, DeleteInitial, Table>where
Table: MySQLTable<'a>,
pub fn delete<Table>(
&self,
table: Table,
) -> DeleteBuilder<'a, Schema, DeleteInitial, Table>where
Table: MySQLTable<'a>,
Starts a DELETE from table.
Without where, the statement deletes every row.
Sourcepub fn with<C>(&self, cte: &C) -> QueryBuilder<'a, Schema, CTEInit>where
C: CTEDefinition<'a>,
pub fn with<C>(&self, cte: &C) -> QueryBuilder<'a, Schema, CTEInit>where
C: CTEDefinition<'a>,
Starts a WITH clause with one common table expression.
Build the CTE with into_cte. Add
more with another .with(..), then start a SELECT, UPDATE or DELETE.
For INSERT ... SELECT, put the WITH on the inner SELECT instead.
§Examples
struct Active;
impl drizzle::core::Tag for Active {
const NAME: &'static str = "active";
}
let active = builder
.select((users.id, users.name))
.from(users)
.r#where(eq(users.active, true))
.into_cte::<Active>();
let query = builder.with(&active).select(active.name).from(&active);
// WITH `active` AS (SELECT ...) SELECT `active`.`name` FROM `active`Source§impl<'a, Schema> QueryBuilder<'a, Schema, CTEInit>
impl<'a, Schema> QueryBuilder<'a, Schema, CTEInit>
Sourcepub fn select<T>(
&self,
columns: T,
) -> SelectBuilder<'a, Schema, SelectInitial, (), T::Marker>
pub fn select<T>( &self, columns: T, ) -> SelectBuilder<'a, Schema, SelectInitial, (), T::Marker>
Starts a SELECT after the WITH clause.
Sourcepub fn select_distinct<T>(
&self,
columns: T,
) -> SelectBuilder<'a, Schema, SelectInitial, (), T::Marker>
pub fn select_distinct<T>( &self, columns: T, ) -> SelectBuilder<'a, Schema, SelectInitial, (), T::Marker>
Starts a SELECT DISTINCT after the WITH clause.
Sourcepub fn update<Table>(
&self,
table: Table,
) -> UpdateBuilder<'a, Schema, UpdateInitial, Table>where
Table: MySQLTable<'a>,
pub fn update<Table>(
&self,
table: Table,
) -> UpdateBuilder<'a, Schema, UpdateInitial, Table>where
Table: MySQLTable<'a>,
Starts an UPDATE after the WITH clause.
Sourcepub fn delete<Table>(
&self,
table: Table,
) -> DeleteBuilder<'a, Schema, DeleteInitial, Table>where
Table: MySQLTable<'a>,
pub fn delete<Table>(
&self,
table: Table,
) -> DeleteBuilder<'a, Schema, DeleteInitial, Table>where
Table: MySQLTable<'a>,
Starts a DELETE after the WITH clause.
Sourcepub fn with<C>(&self, cte: &C) -> Selfwhere
C: CTEDefinition<'a>,
pub fn with<C>(&self, cte: &C) -> Selfwhere
C: CTEDefinition<'a>,
Adds another common table expression to the WITH clause.
Trait Implementations§
Source§impl<'a, Schema: Clone, State: Clone, Table: Clone, Marker: Clone, Row: Clone, Grouped: Clone> Clone for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
impl<'a, Schema: Clone, State: Clone, Table: Clone, Marker: Clone, Row: Clone, Grouped: Clone> Clone for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
Source§impl<'a, Schema: Debug, State: Debug, Table: Debug, Marker: Debug, Row: Debug, Grouped: Debug> Debug for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
impl<'a, Schema: Debug, State: Debug, Table: Debug, Marker: Debug, Row: Debug, Grouped: Debug> Debug for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
Source§impl<'a, Schema, State, Table, Marker, Row, Grouped> ToSQL<'a, MySQLValue<'a>> for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
State: ExecutableState,
impl<'a, Schema, State, Table, Marker, Row, Grouped> ToSQL<'a, MySQLValue<'a>> for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
State: ExecutableState,
Auto Trait Implementations§
impl<'a, Schema, State, Table, Marker, Row, Grouped> Freeze for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
PhantomData<Schema>: Freeze,
PhantomData<State>: Freeze,
PhantomData<Table>: Freeze,
PhantomData<Marker>: Freeze,
PhantomData<Row>: Freeze,
PhantomData<Grouped>: Freeze,
impl<'a, Schema, State, Table, Marker, Row, Grouped> RefUnwindSafe for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
PhantomData<Schema>: RefUnwindSafe,
PhantomData<State>: RefUnwindSafe,
PhantomData<Table>: RefUnwindSafe,
PhantomData<Marker>: RefUnwindSafe,
PhantomData<Row>: RefUnwindSafe,
PhantomData<Grouped>: RefUnwindSafe,
impl<'a, Schema, State, Table, Marker, Row, Grouped> Send for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
PhantomData<Schema>: Send,
PhantomData<State>: Send,
PhantomData<Table>: Send,
PhantomData<Marker>: Send,
PhantomData<Row>: Send,
PhantomData<Grouped>: Send,
impl<'a, Schema, State, Table, Marker, Row, Grouped> Sync for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
PhantomData<Schema>: Sync,
PhantomData<State>: Sync,
PhantomData<Table>: Sync,
PhantomData<Marker>: Sync,
PhantomData<Row>: Sync,
PhantomData<Grouped>: Sync,
impl<'a, Schema, State, Table, Marker, Row, Grouped> Unpin for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
PhantomData<Schema>: Unpin,
PhantomData<State>: Unpin,
PhantomData<Table>: Unpin,
PhantomData<Marker>: Unpin,
PhantomData<Row>: Unpin,
PhantomData<Grouped>: Unpin,
impl<'a, Schema, State, Table, Marker, Row, Grouped> UnsafeUnpin for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
PhantomData<Schema>: UnsafeUnpin,
PhantomData<State>: UnsafeUnpin,
PhantomData<Table>: UnsafeUnpin,
PhantomData<Marker>: UnsafeUnpin,
PhantomData<Row>: UnsafeUnpin,
PhantomData<Grouped>: UnsafeUnpin,
impl<'a, Schema, State, Table, Marker, Row, Grouped> UnwindSafe for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>where
PhantomData<Schema>: UnwindSafe,
PhantomData<State>: UnwindSafe,
PhantomData<Table>: UnwindSafe,
PhantomData<Marker>: UnwindSafe,
PhantomData<Row>: UnwindSafe,
PhantomData<Grouped>: UnwindSafe,
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§impl<'a, V, L, R> ComparisonOperand<'a, V, L> for R
impl<'a, V, L, R> ComparisonOperand<'a, V, L> for R
Source§type Sources = <R as ExprSources>::Sources
type Sources = <R as ExprSources>::Sources
ExprSources::Sources.Source§fn into_comparison_sql(self) -> SQL<'a, V>
fn into_comparison_sql(self) -> SQL<'a, V>
Source§impl<'a, V, E> ExprExt<'a, V> for E
impl<'a, V, E> ExprExt<'a, V> for E
Source§fn eq<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
fn eq<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
=); see eq.Source§fn ne<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
fn ne<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
<>); see ne.Source§fn gt<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
fn gt<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
>); see gt.Source§fn ge<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
fn ge<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
>=); see gte.Source§fn lt<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
fn lt<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
<); see lt.Source§fn le<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
fn le<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
<=); see lte.Source§fn like<R>(
self,
pattern: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual,
<R as ComparisonOperand<'a, V, Self>>::SQLType: Textual,
fn like<R>(
self,
pattern: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual,
<R as ComparisonOperand<'a, V, Self>>::SQLType: Textual,
LIKE); see like.Source§fn not_like<R>(
self,
pattern: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual,
<R as ComparisonOperand<'a, V, Self>>::SQLType: Textual,
fn not_like<R>(
self,
pattern: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), (<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources))>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual,
<R as ComparisonOperand<'a, V, Self>>::SQLType: Textual,
NOT LIKE); see not_like.Source§fn is_null(
self,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, Coalesce<Self::Sources, NonNull>>
fn is_null( self, ) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, Coalesce<Self::Sources, NonNull>>
IS NULL); see is_null.Source§fn is_not_null(
self,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, Coalesce<Self::Sources, NonNull>>
fn is_not_null( self, ) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, Coalesce<Self::Sources, NonNull>>
IS NOT NULL); see is_not_null.Source§fn between<L, H>(
self,
low: L,
high: H,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggregateKind>::Or<<L as ComparisonOperand<'a, V, Self>>::Aggregate> as AggregateKind>::Or<<H as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), ((<L as ComparisonOperand<'a, V, Self>>::Nullable, <L as ComparisonOperand<'a, V, Self>>::Sources), (<H as ComparisonOperand<'a, V, Self>>::Nullable, <H as ComparisonOperand<'a, V, Self>>::Sources)))>where
L: ComparisonOperand<'a, V, Self>,
H: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>,
fn between<L, H>(
self,
low: L,
high: H,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggregateKind>::Or<<L as ComparisonOperand<'a, V, Self>>::Aggregate> as AggregateKind>::Or<<H as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), ((<L as ComparisonOperand<'a, V, Self>>::Nullable, <L as ComparisonOperand<'a, V, Self>>::Sources), (<H as ComparisonOperand<'a, V, Self>>::Nullable, <H as ComparisonOperand<'a, V, Self>>::Sources)))>where
L: ComparisonOperand<'a, V, Self>,
H: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>,
BETWEEN); see between.Source§fn not_between<L, H>(
self,
low: L,
high: H,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggregateKind>::Or<<L as ComparisonOperand<'a, V, Self>>::Aggregate> as AggregateKind>::Or<<H as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), ((<L as ComparisonOperand<'a, V, Self>>::Nullable, <L as ComparisonOperand<'a, V, Self>>::Sources), (<H as ComparisonOperand<'a, V, Self>>::Nullable, <H as ComparisonOperand<'a, V, Self>>::Sources)))>where
L: ComparisonOperand<'a, V, Self>,
H: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>,
fn not_between<L, H>(
self,
low: L,
high: H,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggregateKind>::Or<<L as ComparisonOperand<'a, V, Self>>::Aggregate> as AggregateKind>::Or<<H as ComparisonOperand<'a, V, Self>>::Aggregate>, ((Self::Nullable, Self::Sources), ((<L as ComparisonOperand<'a, V, Self>>::Nullable, <L as ComparisonOperand<'a, V, Self>>::Sources), (<H as ComparisonOperand<'a, V, Self>>::Nullable, <H as ComparisonOperand<'a, V, Self>>::Sources)))>where
L: ComparisonOperand<'a, V, Self>,
H: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>,
NOT BETWEEN); see not_between.Source§fn in_array<I, R>(
self,
values: I,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ((Self::Nullable, Self::Sources), (<R as Expr<'a, V>>::Nullable, <R as ExprSources>::Sources))>where
I: IntoIterator<Item = R>,
R: Expr<'a, V>,
Self::SQLType: Compatible<<R as Expr<'a, V>>::SQLType>,
fn in_array<I, R>(
self,
values: I,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ((Self::Nullable, Self::Sources), (<R as Expr<'a, V>>::Nullable, <R as ExprSources>::Sources))>where
I: IntoIterator<Item = R>,
R: Expr<'a, V>,
Self::SQLType: Compatible<<R as Expr<'a, V>>::SQLType>,
IN (...)); see in_array.Source§fn not_in_array<I, R>(
self,
values: I,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ((Self::Nullable, Self::Sources), (<R as Expr<'a, V>>::Nullable, <R as ExprSources>::Sources))>where
I: IntoIterator<Item = R>,
R: Expr<'a, V>,
Self::SQLType: Compatible<<R as Expr<'a, V>>::SQLType>,
fn not_in_array<I, R>(
self,
values: I,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ((Self::Nullable, Self::Sources), (<R as Expr<'a, V>>::Nullable, <R as ExprSources>::Sources))>where
I: IntoIterator<Item = R>,
R: Expr<'a, V>,
Self::SQLType: Compatible<<R as Expr<'a, V>>::SQLType>,
NOT IN (...)); see
not_in_array.Source§fn in_subquery<S>(
self,
subquery: S,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ((Self::Nullable, Self::Sources), (<S as Expr<'a, V>>::Nullable, <S as ExprSources>::Sources))>
fn in_subquery<S>( self, subquery: S, ) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ((Self::Nullable, Self::Sources), (<S as Expr<'a, V>>::Nullable, <S as ExprSources>::Sources))>
IN (SELECT ...)); see
in_subquery.Source§fn not_in_subquery<S>(
self,
subquery: S,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ((Self::Nullable, Self::Sources), (<S as Expr<'a, V>>::Nullable, <S as ExprSources>::Sources))>
fn not_in_subquery<S>( self, subquery: S, ) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ((Self::Nullable, Self::Sources), (<S as Expr<'a, V>>::Nullable, <S as ExprSources>::Sources))>
NOT IN (SELECT ...)); see
not_in_subquery.Source§fn is_distinct_from<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, Coalesce<(Self::Sources, <R as ComparisonOperand<'a, V, Self>>::Sources), NonNull>>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
fn is_distinct_from<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, Coalesce<(Self::Sources, <R as ComparisonOperand<'a, V, Self>>::Sources), NonNull>>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
IS DISTINCT FROM); see is_distinct_from.Source§fn is_not_distinct_from<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, Coalesce<(Self::Sources, <R as ComparisonOperand<'a, V, Self>>::Sources), NonNull>>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
fn is_not_distinct_from<R>(
self,
other: R,
) -> SQLExpr<'a, V, <<V as SQLParam>::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, Coalesce<(Self::Sources, <R as ComparisonOperand<'a, V, Self>>::Sources), NonNull>>where
R: ComparisonOperand<'a, V, Self>,
Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,
IS NOT DISTINCT FROM); see is_not_distinct_from.