pub struct QueryBuilder<'a, Schema = (), State = (), Table = (), Marker = (), Row = (), Grouped = ()> {
pub sql: SQL<'a, PostgresValue<'a>>,
/* private fields */
}Expand description
Builds PostgreSQL statements as SQL plus bound parameters, without a connection.
Create one with QueryBuilder::new, then start a statement with
select, insert,
update, delete or
with. Each call returns a builder whose type
tracks the clauses added so far, so out-of-order clauses (such as
.where() before .from()) do not compile. Call .to_sql() to get the
statement. The driver crates wrap this builder to run the query.
Schema is the schema type from #[derive(PostgresSchema)]. The other
type parameters are builder state and are inferred.
§Examples
use drizzle::core::expr::eq;
let query = db
.select((user.id, user.name))
.from(user)
.r#where(eq(user.name, "Alice"));
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."id", "users"."name" FROM "users" WHERE "users"."name" = $1"#
);Fields§
§sql: SQL<'a, PostgresValue<'a>>The SQL built so far.
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, PostgresValue<'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, PostgresValue<'a>>,
E::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
E::SQLType: BooleanLike,
Sourcepub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> DeleteBuilder<'a, S, DeleteReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
pub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> DeleteBuilder<'a, S, DeleteReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
Adds RETURNING columns, so the statement returns the deleted rows.
Source§impl<'a, S, T> QueryBuilder<'a, S, DeleteWhereSet, T>
impl<'a, S, T> QueryBuilder<'a, S, DeleteWhereSet, T>
Sourcepub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> DeleteBuilder<'a, S, DeleteReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
pub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> DeleteBuilder<'a, S, DeleteReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
Adds RETURNING columns after WHERE.
Source§impl<'a, Schema, Table> QueryBuilder<'a, Schema, InsertInitial, Table>where
Table: PostgresTable<'a>,
impl<'a, Schema, Table> QueryBuilder<'a, Schema, InsertInitial, Table>where
Table: PostgresTable<'a>,
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. Shorthand for .values([row]).
§Examples
let query = db.insert(user).value(InsertUser::new("Alice"));
assert_eq!(query.to_sql().sql(), r#"INSERT INTO "users" ("name") VALUES ($1)"#);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 the given rows, built with the table’s Insert* model.
Every row has the same model type. A column a row leaves unset gets
its database default; when rows set different columns, every row lists
the union of the columns, with DEFAULT where it sets none.
§Examples
let query = db
.insert(user)
.values([InsertUser::new("Alice"), InsertUser::new("Bob")]);
assert_eq!(
query.to_sql().sql(),
r#"INSERT INTO "users" ("name") VALUES ($1), ($2)"#
);Sourcepub fn columns<Columns>(
self,
columns: Columns,
) -> InsertBuilder<'a, Schema, InsertColumnsSet<Columns::Columns>, Table>where
Columns: InsertTargetColumns<'a, PostgresValue<'a>, Table>,
pub fn columns<Columns>(
self,
columns: Columns,
) -> InsertBuilder<'a, Schema, InsertColumnsSet<Columns::Columns>, Table>where
Columns: InsertTargetColumns<'a, PostgresValue<'a>, Table>,
Sets the target columns, in order, for INSERT ... SELECT.
The list must include every required column (non-null without a
default). Continue with select, whose columns must
match these in number, order and type.
§Examples
let query = db
.insert(post)
.columns((post.author_id, post.title))
.select(db.select((user.id, user.name)).from(user));
assert_eq!(
query.to_sql().sql(),
r#"INSERT INTO "posts" ("author_id", "title") SELECT "users"."id", "users"."name" FROM "users""#
);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, PostgresValue<'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, PostgresValue<'a>, Table, R> + MarkerScopeValidFor<ScopeProof> + MarkerAggValidFor<Q::Grouped, AggProof>,
Inserts the rows of a SELECT into every insertable column of the table.
The query’s columns must match the table’s insertable columns in
number, order, type and nullability, and the query must pass the
usual scope and GROUP BY checks; all of this is checked at compile
time. To fill only some columns, call columns first.
Sourcepub fn select_raw<Q>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Q: ToSQL<'a, PostgresValue<'a>>,
pub fn select_raw<Q>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Q: ToSQL<'a, PostgresValue<'a>>,
Inserts the rows of a raw SELECT, with no target column list.
Nothing about the query is checked: not its column count, types,
nullability, sources or aggregates. Prefer select.
Source§impl<'a, Schema, Table, Targets> QueryBuilder<'a, Schema, InsertColumnsSet<Targets>, Table>where
Table: PostgresTable<'a> + InsertSelectTable,
impl<'a, Schema, Table, Targets> QueryBuilder<'a, Schema, InsertColumnsSet<Targets>, Table>where
Table: PostgresTable<'a> + InsertSelectTable,
Sourcepub fn select<Q, R, RequiredProof, ScopeProof, AggProof>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Targets: IncludesRequired<Table::RequiredColumns, RequiredProof>,
Q: IntoSelectQuery<'a, Schema, R>,
Q::Marker: PartialInsertSelectCompatible<'a, PostgresValue<'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>,
Q: IntoSelectQuery<'a, Schema, R>,
Q::Marker: PartialInsertSelectCompatible<'a, PostgresValue<'a>, Targets> + MarkerScopeValidFor<ScopeProof> + MarkerAggValidFor<Q::Grouped, AggProof>,
Inserts the rows of a SELECT into the columns chosen with .columns(...).
The query’s columns must match the target columns in number, order,
type and nullability, and the query must pass the usual scope and
GROUP BY checks; all of this is checked at compile time.
Sourcepub fn select_raw<Q, RequiredProof>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Targets: IncludesRequired<Table::RequiredColumns, RequiredProof>,
Q: ToSQL<'a, PostgresValue<'a>>,
pub fn select_raw<Q, RequiredProof>(
self,
query: Q,
) -> InsertBuilder<'a, Schema, InsertValuesSet, Table>where
Targets: IncludesRequired<Table::RequiredColumns, RequiredProof>,
Q: ToSQL<'a, PostgresValue<'a>>,
Inserts the rows of a raw SELECT into the chosen target columns.
Only the target list is checked (it must include every required
column); the query itself is not. Prefer select.
Source§impl<'a, S, T> QueryBuilder<'a, S, InsertValuesSet, T>
impl<'a, S, T> QueryBuilder<'a, S, InsertValuesSet, T>
Sourcepub fn on_conflict<C: ConflictTarget<T>>(
self,
target: C,
) -> OnConflictBuilder<'a, S, T>
pub fn on_conflict<C: ConflictTarget<T>>( self, target: C, ) -> OnConflictBuilder<'a, S, T>
Starts ON CONFLICT (columns), handling rows that would violate a
unique constraint on the target.
The target is a primary-key column, a unique column, or a unique
index (anything implementing ConflictTarget<T>, which the macros
generate). Finish with .do_nothing() or .do_update(update_model).
§Examples
fn main() {
use drizzle::postgres::prelude::*;
use drizzle::postgres::builder::QueryBuilder;
#[PostgresTable(name = "users")]
struct User {
#[column(serial, primary)]
id: i32,
name: String,
#[column(unique)]
email: Option<String>,
}
#[PostgresIndex(unique)]
struct UserEmailIdx(User::email);
#[derive(PostgresSchema)]
struct Schema {
user: User,
user_email_idx: UserEmailIdx,
}
let builder = QueryBuilder::new::<Schema>();
let schema = Schema::new();
let user = schema.user;
// Target a specific column
builder.insert(user).values([InsertUser::new("Alice")])
.on_conflict(user.id).do_nothing();
// DO UPDATE with new values
let query = builder.insert(user).values([InsertUser::new("Alice")])
.on_conflict(user.email).do_update(UpdateUser::default().with_name("updated"));
assert_eq!(
query.to_sql().sql(),
r#"INSERT INTO "users" ("name") VALUES ($1) ON CONFLICT ("email") DO UPDATE SET "name" = $2"#
);
// Target a unique index
builder.insert(user).values([InsertUser::new("Alice")])
.on_conflict(schema.user_email_idx).do_nothing();
}Sourcepub fn on_conflict_on_constraint<C: NamedConstraint<T>>(
self,
target: C,
) -> OnConflictBuilder<'a, S, T>
pub fn on_conflict_on_constraint<C: NamedConstraint<T>>( self, target: C, ) -> OnConflictBuilder<'a, S, T>
Starts ON CONFLICT ON CONSTRAINT name, naming the unique constraint
to handle.
The target is a unique column or a named unique constraint (anything
implementing NamedConstraint<T>, which the macros generate). A
standalone unique index is not a constraint, so PostgreSQL rejects it
here; use on_conflict for indexes. Finish with
.do_nothing() or .do_update(update_model).
§Examples
fn main() {
use drizzle::postgres::prelude::*;
use drizzle::postgres::builder::QueryBuilder;
#[PostgresTable(name = "users")]
struct User {
#[column(serial, primary)]
id: i32,
name: String,
#[column(unique)]
email: Option<String>,
}
#[derive(PostgresSchema)]
struct Schema {
user: User,
}
let builder = QueryBuilder::new::<Schema>();
let schema = Schema::new();
let user = schema.user;
builder.insert(user).values([InsertUser::new("Alice")])
.on_conflict_on_constraint(user.email).do_nothing();
}Sourcepub fn on_conflict_do_nothing(
self,
) -> InsertBuilder<'a, S, InsertOnConflictSet, T>
pub fn on_conflict_do_nothing( self, ) -> InsertBuilder<'a, S, InsertOnConflictSet, T>
Adds ON CONFLICT DO NOTHING with no target: rows that violate any
unique or exclusion constraint are skipped.
Sourcepub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> InsertBuilder<'a, S, InsertReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
pub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> InsertBuilder<'a, S, InsertReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
Adds RETURNING columns, so the statement returns the inserted rows.
Pass a column, a tuple of columns, or () for all columns. Only
columns of the target table are allowed.
§Examples
let query = db
.insert(user)
.values([InsertUser::new("Alice")])
.returning((user.id, user.name));
assert_eq!(
query.to_sql().sql(),
r#"INSERT INTO "users" ("name") VALUES ($1) RETURNING "users"."id", "users"."name""#
);Source§impl<'a, S, T> QueryBuilder<'a, S, InsertOnConflictSet, T>
impl<'a, S, T> QueryBuilder<'a, S, InsertOnConflictSet, T>
Sourcepub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> InsertBuilder<'a, S, InsertReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
pub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> InsertBuilder<'a, S, InsertReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
Adds RETURNING columns after the ON CONFLICT clause.
Rows skipped by DO NOTHING are not returned.
Source§impl<'a, S, T> QueryBuilder<'a, S, InsertDoUpdateSet, T>
impl<'a, S, T> QueryBuilder<'a, S, InsertDoUpdateSet, T>
Sourcepub fn where<E, ScopeProof>(
self,
condition: E,
) -> InsertBuilder<'a, S, InsertOnConflictSet, T>where
E: ExprSources + Expr<'a, PostgresValue<'a>>,
E::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
E::SQLType: BooleanLike,
pub fn where<E, ScopeProof>(
self,
condition: E,
) -> InsertBuilder<'a, S, InsertOnConflictSet, T>where
E: ExprSources + Expr<'a, PostgresValue<'a>>,
E::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
E::SQLType: BooleanLike,
Adds a WHERE condition to DO UPDATE: conflicting rows are updated
only when it holds.
Renders ON CONFLICT (...) DO UPDATE SET ... WHERE condition. The
condition may only use columns of the target table.
Sourcepub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> InsertBuilder<'a, S, InsertReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
pub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> InsertBuilder<'a, S, InsertReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
Adds RETURNING columns after DO UPDATE SET.
Source§impl<'a, S, M> QueryBuilder<'a, S, SelectInitial, (), M>
impl<'a, S, M> QueryBuilder<'a, S, SelectInitial, (), M>
Sourcepub fn from<T>(
self,
query: T,
) -> SelectBuilder<'a, S, SelectFromSet, T, FromMarker<M, T>, <M as ResolveRow<T>>::Row>
pub fn from<T>( self, query: T, ) -> SelectBuilder<'a, S, SelectFromSet, T, FromMarker<M, T>, <M as ResolveRow<T>>::Row>
Sets the FROM source: a table, a view, an aliased table, a derived
table (.alias(...)), or a CTE.
§Examples
let query = db.select(()).from(user);
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."id", "users"."name", "users"."email" FROM "users""#
);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>>(
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>>( 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 an inner JOIN ... ON ....
Pass (source, condition), or a bare table to join on its foreign key
to the previous table. The tables the condition reads are checked
against the query’s scope at compile time, where the query is run
(.all(), .get(), .rows()).
Other join kinds have their own methods:
left_join, right_join, full_join, inner_join, their _outer
forms, natural_* joins, *_join_using, and the *_lateral joins.
§Examples
use drizzle::core::expr::eq;
let query = db
.select((user.name, post.title))
.from(user)
.join((post, eq(post.author_id, user.id)));
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."name", "posts"."title" FROM "users" JOIN "posts" ON "posts"."author_id" = "users"."id""#
);Sourcepub fn natural_join<J: JoinSource<'a>>(
self,
source: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, InnerJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, InnerJoin>>::Row, G>
pub fn natural_join<J: JoinSource<'a>>( self, source: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, InnerJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, InnerJoin>>::Row, G>
Adds a NATURAL join of the kind named by the method.
The database joins on every column name both sides share, so
this takes only a table or other source, with no ON condition.
Sourcepub fn natural_left_join<J: JoinSource<'a>>(
self,
source: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, LeftJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, LeftJoin>>::Row, G>
pub fn natural_left_join<J: JoinSource<'a>>( self, source: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, LeftJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, LeftJoin>>::Row, G>
Adds a NATURAL join of the kind named by the method.
The database joins on every column name both sides share, so
this takes only a table or other source, with no ON condition.
Sourcepub fn left_join<J: JoinArg<'a, T>>(
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>>( 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 of the kind named by the method, with an ON condition.
Pass (source, condition), or a bare table to join on its
foreign key to the previous table. An outer join makes the
columns of its nullable side (the joined source for LEFT,
the earlier sources for RIGHT, both for FULL) decode as
Option.
Sourcepub fn left_outer_join<J: JoinArg<'a, T>>(
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>>( 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 of the kind named by the method, with an ON condition.
Pass (source, condition), or a bare table to join on its
foreign key to the previous table. An outer join makes the
columns of its nullable side (the joined source for LEFT,
the earlier sources for RIGHT, both for FULL) decode as
Option.
Sourcepub fn natural_left_outer_join<J: JoinSource<'a>>(
self,
source: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, LeftJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, LeftJoin>>::Row, G>
pub fn natural_left_outer_join<J: JoinSource<'a>>( self, source: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, LeftJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, LeftJoin>>::Row, G>
Adds a NATURAL join of the kind named by the method.
The database joins on every column name both sides share, so
this takes only a table or other source, with no ON condition.
Sourcepub fn natural_right_join<J: JoinSource<'a>>(
self,
source: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, RightJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, RightJoin>>::Row, G>
pub fn natural_right_join<J: JoinSource<'a>>( self, source: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, RightJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, RightJoin>>::Row, G>
Adds a NATURAL join of the kind named by the method.
The database joins on every column name both sides share, so
this takes only a table or other source, with no ON condition.
Sourcepub fn right_join<J: JoinArg<'a, T>>(
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>>( 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 of the kind named by the method, with an ON condition.
Pass (source, condition), or a bare table to join on its
foreign key to the previous table. An outer join makes the
columns of its nullable side (the joined source for LEFT,
the earlier sources for RIGHT, both for FULL) decode as
Option.
Sourcepub fn right_outer_join<J: JoinArg<'a, T>>(
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>>( 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 of the kind named by the method, with an ON condition.
Pass (source, condition), or a bare table to join on its
foreign key to the previous table. An outer join makes the
columns of its nullable side (the joined source for LEFT,
the earlier sources for RIGHT, both for FULL) decode as
Option.
Sourcepub fn natural_right_outer_join<J: JoinSource<'a>>(
self,
source: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, RightJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, RightJoin>>::Row, G>
pub fn natural_right_outer_join<J: JoinSource<'a>>( self, source: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, RightJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, RightJoin>>::Row, G>
Adds a NATURAL join of the kind named by the method.
The database joins on every column name both sides share, so
this takes only a table or other source, with no ON condition.
Sourcepub fn natural_full_join<J: JoinSource<'a>>(
self,
source: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, FullJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, FullJoin>>::Row, G>
pub fn natural_full_join<J: JoinSource<'a>>( self, source: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, FullJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, FullJoin>>::Row, G>
Adds a NATURAL join of the kind named by the method.
The database joins on every column name both sides share, so
this takes only a table or other source, with no ON condition.
Sourcepub fn full_join<J: JoinArg<'a, T>>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, FullJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, FullJoin, J::OnSources>>::Row, G>
pub fn full_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, FullJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, FullJoin, J::OnSources>>::Row, G>
Adds a join of the kind named by the method, with an ON condition.
Pass (source, condition), or a bare table to join on its
foreign key to the previous table. An outer join makes the
columns of its nullable side (the joined source for LEFT,
the earlier sources for RIGHT, both for FULL) decode as
Option.
Sourcepub fn full_outer_join<J: JoinArg<'a, T>>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, FullJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, FullJoin, J::OnSources>>::Row, G>
pub fn full_outer_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, FullJoin, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, FullJoin, J::OnSources>>::Row, G>
Adds a join of the kind named by the method, with an ON condition.
Pass (source, condition), or a bare table to join on its
foreign key to the previous table. An outer join makes the
columns of its nullable side (the joined source for LEFT,
the earlier sources for RIGHT, both for FULL) decode as
Option.
Sourcepub fn natural_full_outer_join<J: JoinSource<'a>>(
self,
source: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, FullJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, FullJoin>>::Row, G>
pub fn natural_full_outer_join<J: JoinSource<'a>>( self, source: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, FullJoin>>::Marker, <M as JoinStep<R, J::JoinedTable, FullJoin>>::Row, G>
Adds a NATURAL join of the kind named by the method.
The database joins on every column name both sides share, so
this takes only a table or other source, with no ON condition.
Sourcepub fn inner_join<J: JoinArg<'a, T>>(
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>>( 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 of the kind named by the method, with an ON condition.
Pass (source, condition), or a bare table to join on its
foreign key to the previous table. An outer join makes the
columns of its nullable side (the joined source for LEFT,
the earlier sources for RIGHT, both for FULL) decode as
Option.
Sourcepub fn left_join_using<U: PostgresTable<'a>>(
self,
table: U,
columns: impl ToSQL<'a, PostgresValue<'a>>,
) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, LeftJoin>>::Marker, <M as JoinStep<R, U, LeftJoin>>::Row, G>
pub fn left_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, LeftJoin>>::Marker, <M as JoinStep<R, U, LeftJoin>>::Row, G>
Adds a join of the kind named by the method, with
USING (columns): joins on equal values of same-named columns.
Pass bare column names, such as SQL::ident("id"); see
join_using.
Sourcepub fn left_outer_join_using<U: PostgresTable<'a>>(
self,
table: U,
columns: impl ToSQL<'a, PostgresValue<'a>>,
) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, LeftJoin>>::Marker, <M as JoinStep<R, U, LeftJoin>>::Row, G>
pub fn left_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, LeftJoin>>::Marker, <M as JoinStep<R, U, LeftJoin>>::Row, G>
Adds a join of the kind named by the method, with
USING (columns): joins on equal values of same-named columns.
Pass bare column names, such as SQL::ident("id"); see
join_using.
Sourcepub fn right_join_using<U: PostgresTable<'a>>(
self,
table: U,
columns: impl ToSQL<'a, PostgresValue<'a>>,
) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, RightJoin>>::Marker, <M as JoinStep<R, U, RightJoin>>::Row, G>
pub fn right_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, RightJoin>>::Marker, <M as JoinStep<R, U, RightJoin>>::Row, G>
Adds a join of the kind named by the method, with
USING (columns): joins on equal values of same-named columns.
Pass bare column names, such as SQL::ident("id"); see
join_using.
Sourcepub fn right_outer_join_using<U: PostgresTable<'a>>(
self,
table: U,
columns: impl ToSQL<'a, PostgresValue<'a>>,
) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, RightJoin>>::Marker, <M as JoinStep<R, U, RightJoin>>::Row, G>
pub fn right_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, RightJoin>>::Marker, <M as JoinStep<R, U, RightJoin>>::Row, G>
Adds a join of the kind named by the method, with
USING (columns): joins on equal values of same-named columns.
Pass bare column names, such as SQL::ident("id"); see
join_using.
Sourcepub fn full_join_using<U: PostgresTable<'a>>(
self,
table: U,
columns: impl ToSQL<'a, PostgresValue<'a>>,
) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, FullJoin>>::Marker, <M as JoinStep<R, U, FullJoin>>::Row, G>
pub fn full_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, FullJoin>>::Marker, <M as JoinStep<R, U, FullJoin>>::Row, G>
Adds a join of the kind named by the method, with
USING (columns): joins on equal values of same-named columns.
Pass bare column names, such as SQL::ident("id"); see
join_using.
Sourcepub fn full_outer_join_using<U: PostgresTable<'a>>(
self,
table: U,
columns: impl ToSQL<'a, PostgresValue<'a>>,
) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, FullJoin>>::Marker, <M as JoinStep<R, U, FullJoin>>::Row, G>
pub fn full_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, FullJoin>>::Marker, <M as JoinStep<R, U, FullJoin>>::Row, G>
Adds a join of the kind named by the method, with
USING (columns): joins on equal values of same-named columns.
Pass bare column names, such as SQL::ident("id"); see
join_using.
Sourcepub fn inner_join_using<U: PostgresTable<'a>>(
self,
table: U,
columns: impl ToSQL<'a, PostgresValue<'a>>,
) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, InnerJoin>>::Marker, <M as JoinStep<R, U, InnerJoin>>::Row, G>
pub fn inner_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, InnerJoin>>::Marker, <M as JoinStep<R, U, InnerJoin>>::Row, G>
Adds a join of the kind named by the method, with
USING (columns): joins on equal values of same-named columns.
Pass bare column names, such as SQL::ident("id"); see
join_using.
Sourcepub fn join_using<U: PostgresTable<'a>>(
self,
table: U,
columns: impl ToSQL<'a, PostgresValue<'a>>,
) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, InnerJoin>>::Marker, <M as JoinStep<R, U, InnerJoin>>::Row, G>
pub fn join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as JoinStep<R, U, InnerJoin>>::Marker, <M as JoinStep<R, U, InnerJoin>>::Row, G>
Adds JOIN table USING (columns), joining on equal values of
same-named columns.
columns is rendered as given, and PostgreSQL requires bare
names here: pass SQL::ident("id"), not a table column, which
renders qualified.
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: every row of the left side paired with every row
of source.
For backwards compatibility, (source, condition) is also accepted and
renders the equivalent INNER JOIN ... ON ....
§Examples
let query = db.select((user.name, post.title)).from(user).cross_join(post);
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."name", "posts"."title" FROM "users" CROSS JOIN "posts""#
);Sourcepub fn inner_join_lateral<J>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, Lateral<InnerJoin>, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, Lateral<InnerJoin>, J::OnSources>>::Row, G>where
J: LateralArg<'a, PostgresValue<'a>>,
M: JoinStep<R, J::JoinedTable, Lateral<InnerJoin>, J::OnSources>,
pub fn inner_join_lateral<J>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, Lateral<InnerJoin>, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, Lateral<InnerJoin>, J::OnSources>>::Row, G>where
J: LateralArg<'a, PostgresValue<'a>>,
M: JoinStep<R, J::JoinedTable, Lateral<InnerJoin>, J::OnSources>,
Adds INNER JOIN LATERAL (subquery) AS alias ON condition.
A lateral subquery can refer to columns of the sources joined before
it. Pass (derived_table, condition), where the derived table comes
from .alias(tag) on a SELECT.
Sourcepub fn left_join_lateral<J, SelectionProof>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, Lateral<LeftJoin>, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, Lateral<LeftJoin>, J::OnSources>>::Row, G>where
J: LateralArg<'a, PostgresValue<'a>>,
M: JoinStep<R, J::JoinedTable, Lateral<LeftJoin>, J::OnSources> + LeftLateralSelection<SelectionProof>,
pub fn left_join_lateral<J, SelectionProof>(
self,
arg: J,
) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as JoinStep<R, J::JoinedTable, Lateral<LeftJoin>, J::OnSources>>::Marker, <M as JoinStep<R, J::JoinedTable, Lateral<LeftJoin>, J::OnSources>>::Row, G>where
J: LateralArg<'a, PostgresValue<'a>>,
M: JoinStep<R, J::JoinedTable, Lateral<LeftJoin>, J::OnSources> + LeftLateralSelection<SelectionProof>,
Adds LEFT JOIN LATERAL (subquery) AS alias ON condition.
Like inner_join_lateral, but keeps
left rows with no match. With select(()) the lateral source decodes
as an Option of its row; an explicit column list may only read
sources joined before the lateral join.
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, PostgresValue<'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, PostgresValue<'a>>,
M: JoinStep<R, Source::JoinedTable, Lateral<InnerJoin>>,
Adds CROSS JOIN LATERAL (subquery) AS alias, with no ON condition.
The subquery runs once per left row and can refer to its columns.
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 condition.
The condition must be boolean, such as eq(...), and(...) or a
boolean column. Every column it uses must come from a source in
FROM or a join. The compiler checks this where the query is run
(.all(), .get(), .rows()): a column of another table fails there
with “X is not in this query’s FROM/JOIN scope”.
§Examples
use drizzle::core::expr::{and, eq, gt};
let query = db
.select(user.id)
.from(user)
.r#where(and(eq(user.name, "Alice"), gt(user.id, 10)));
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."id" FROM "users" WHERE ("users"."name" = $1 AND "users"."id" > $2)"#
);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 list: one expression or a tuple of them.
Non-aggregate columns in the SELECT list must appear in the
GROUP BY list, with one exception: grouping by a table’s
single-column primary key determines the whole row, so any column of
that table may be selected without being listed (PostgreSQL allows
this too).
§Examples
use drizzle::core::expr::{count, gt};
let query = db
.select((post.author_id, count(post.id)))
.from(post)
.group_by(post.author_id)
.having(gt(count(post.id), 5));
assert_eq!(
query.to_sql().sql(),
r#"SELECT "posts"."author_id", COUNT ("posts"."id") FROM "posts" GROUP BY "posts"."author_id" HAVING COUNT ("posts"."id")> $1"#
);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, SelectGroupSet, T, <M as HasScope>::With<E::Sources>, R, G>
pub fn having<E>( self, condition: E, ) -> SelectBuilder<'a, S, SelectGroupSet, T, <M as HasScope>::With<E::Sources>, R, G>
Adds a HAVING condition, which filters groups after GROUP BY.
See group_by for an example.
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<TOrderBy>(
self,
expressions: TOrderBy,
) -> SelectBuilder<'a, S, SelectOrderSet, T, <M as HasScope>::With<TOrderBy::Sources>, R, G>
pub fn order_by<TOrderBy>( self, expressions: TOrderBy, ) -> SelectBuilder<'a, S, SelectOrderSet, T, <M as HasScope>::With<TOrderBy::Sources>, R, G>
Adds ORDER BY.
Pass a column (ascending by default), asc(col) / desc(col), or a
tuple of them. An array also works when every term reads the same
table; terms over different tables go in a tuple.
§Examples
use drizzle::core::{asc, desc};
let query = db
.select(user.name)
.from(user)
.order_by([asc(user.name), desc(user.id)]);
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."name" FROM "users" ORDER BY "users"."name" ASC, "users"."id" DESC"#
);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<TOrderBy>(
self,
expressions: TOrderBy,
) -> SelectBuilder<'a, S, SelectOrderSet, T, M, R, G>where
TOrderBy: ToSQL<'a, PostgresValue<'a>>,
pub fn order_by<TOrderBy>(
self,
expressions: TOrderBy,
) -> SelectBuilder<'a, S, SelectOrderSet, T, M, R, G>where
TOrderBy: ToSQL<'a, PostgresValue<'a>>,
Adds ORDER BY to a compound (UNION / INTERSECT / EXCEPT) query.
The terms sort the combined output, so column references render
unqualified ("name", not "users"."name"), as PostgreSQL requires.
§Examples
let query = db
.select(user.name)
.from(user)
.union_all(db.select(post.title).from(post))
.order_by(user.name);
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."name" FROM "users" UNION ALL SELECT "posts"."title" FROM "posts" ORDER BY "name""#
);Source§impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Limit>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Limit>,
Sourcepub fn limit<P>(
self,
limit: P,
) -> SelectBuilder<'a, S, SelectLimitSet, T, M, R, G>where
P: PaginationArg<'a, PostgresValue<'a>>,
pub fn limit<P>(
self,
limit: P,
) -> SelectBuilder<'a, S, SelectLimitSet, T, M, R, G>where
P: PaginationArg<'a, PostgresValue<'a>>,
Adds LIMIT n, returning at most n rows.
n is a non-negative integer (bound as a parameter) or a placeholder.
§Examples
let query = db.select(user.id).from(user).limit(5);
assert_eq!(query.to_sql().sql(), r#"SELECT "users"."id" FROM "users" LIMIT $1"#);§Panics
Panics when a signed numeric argument is negative or a numeric value
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<Offset>,
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>where
State: ClauseAllowed<Offset>,
Sourcepub fn offset<P>(
self,
offset: P,
) -> SelectBuilder<'a, S, SelectOffsetSet, T, M, R, G>where
P: PaginationArg<'a, PostgresValue<'a>>,
pub fn offset<P>(
self,
offset: P,
) -> SelectBuilder<'a, S, SelectOffsetSet, T, M, R, G>where
P: PaginationArg<'a, PostgresValue<'a>>,
Adds OFFSET n, skipping the first n rows.
n is a non-negative integer (bound as a parameter) or a placeholder.
§Examples
let query = db.select(user.id).from(user).limit(10).offset(20);
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."id" FROM "users" LIMIT $1 OFFSET $2"#
);§Panics
Panics when a signed numeric argument is negative or a numeric value
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<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, PostgresValue<'a>, Tag, <M as DerivedSelection<'a, PostgresValue<'a>, PostgresSchemaType, T>>::Projection, Self>where
Tag: Tag,
M: DerivedSelection<'a, PostgresValue<'a>, PostgresSchemaType, T> + MarkerAggValidFor<G, AggProof>,
<M as DerivedSelection<'a, PostgresValue<'a>, PostgresSchemaType, T>>::Projection: DerivedProjection<Tag>,
pub fn alias<Tag, AggProof>(
self,
_tag: Tag,
) -> Derived<'a, PostgresValue<'a>, Tag, <M as DerivedSelection<'a, PostgresValue<'a>, PostgresSchemaType, T>>::Projection, Self>where
Tag: Tag,
M: DerivedSelection<'a, PostgresValue<'a>, PostgresSchemaType, T> + MarkerAggValidFor<G, AggProof>,
<M as DerivedSelection<'a, PostgresValue<'a>, PostgresSchemaType, T>>::Projection: DerivedProjection<Tag>,
Turns this SELECT into a derived table, (SELECT ...) AS tag.
The result can be used in .from(...) or a lateral join; read its
columns with .fields().
§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>
impl<'a, S, State, T, M, R, G> QueryBuilder<'a, S, State, T, M, R, G>
Sourcepub fn into_cte<Tag: Tag + 'static>(
self,
) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased<Tag>, Self>
pub fn into_cte<Tag: Tag + 'static>( self, ) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased<Tag>, Self>
Turns this SELECT into a common table expression named Tag::NAME.
The result has the same columns as the FROM table. Pass it to
QueryBuilder::with, and read its columns through its .table field;
see QueryBuilder::with for an example.
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<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
pub fn union<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
Combines this query with other using UNION, which drops duplicate rows.
Both queries must decode to the same row type, which the compiler
checks. The union_all, intersect, intersect_all, except and
except_all methods work the same way.
§Examples
let query = db
.select(user.name)
.from(user)
.union(db.select(post.title).from(post));
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."name" FROM "users" UNION SELECT "posts"."title" FROM "posts""#
);Sourcepub fn union_all<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
pub fn union_all<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
Combines this query with other using UNION ALL, which keeps duplicates.
Sourcepub fn intersect<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
pub fn intersect<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
Keeps the rows present in both queries (INTERSECT), without duplicates.
Sourcepub fn intersect_all<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
pub fn intersect_all<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
Keeps the rows present in both queries (INTERSECT ALL), with duplicates.
Sourcepub fn except<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
pub fn except<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
Keeps the rows of this query that are not in other (EXCEPT), without duplicates.
Sourcepub fn except_all<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
pub fn except_all<M2>(
self,
other: impl IntoSelect<'a, S, M2, R>,
) -> SelectBuilder<'a, S, SelectSetOpSet, T, <M as SetOperand<M2>>::Combined, R, G>where
M: SetOperand<M2>,
Keeps the rows of this query that are not in other (EXCEPT ALL), with duplicates.
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, T, M, R, G>
pub fn for_update(self) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>
Adds FOR UPDATE, locking the selected rows against updates and
deletes by other transactions until this one ends.
Follow with nowait or skip_locked
to change what happens when a row is already locked.
§Examples
let query = db.select(user.id).from(user).for_update().skip_locked();
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."id" FROM "users" FOR UPDATE SKIP LOCKED"#
);Adds FOR SHARE: other transactions can still read and share-lock the
rows, but cannot update or delete them.
Sourcepub fn for_no_key_update(self) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>
pub fn for_no_key_update(self) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>
Adds FOR NO KEY UPDATE: like FOR UPDATE, but does not block
FOR KEY SHARE locks (for example, foreign-key checks).
Adds FOR KEY SHARE: blocks deletes and key changes, but allows other
updates.
Sourcepub fn for_update_of<U: PostgresTable<'a>>(
self,
table: U,
) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>
pub fn for_update_of<U: PostgresTable<'a>>( self, table: U, ) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>
Adds FOR UPDATE OF table, locking rows of that table only.
§Examples
use drizzle::core::expr::eq;
let query = db
.select((user.id, post.id))
.from(user)
.join((post, eq(post.author_id, user.id)))
.for_update_of(user);
assert!(query.to_sql().sql().ends_with(r#"FOR UPDATE OF "users""#));Adds FOR SHARE OF table, locking rows of that table only.
Source§impl<S, T, M, R, G> QueryBuilder<'_, S, SelectForSet, T, M, R, G>
impl<S, T, M, R, G> QueryBuilder<'_, S, SelectForSet, T, M, R, G>
Sourcepub fn nowait(self) -> Self
pub fn nowait(self) -> Self
Adds NOWAIT: the query fails at once instead of waiting when a row
is already locked.
Sourcepub fn skip_locked(self) -> Self
pub fn skip_locked(self) -> Self
Adds SKIP LOCKED: rows already locked by another transaction are
left out of the result instead of waited for.
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 new column values from the table’s Update* model.
Only the fields set on the model (with .with_*) are written.
Source§impl<'a, S, T> QueryBuilder<'a, S, UpdateSetClauseSet, T>
impl<'a, S, T> QueryBuilder<'a, S, UpdateSetClauseSet, T>
Sourcepub fn from<F>(
self,
source: F,
) -> UpdateBuilder<'a, S, UpdateFromSet, T, Cons<F, Nil>>
pub fn from<F>( self, source: F, ) -> UpdateBuilder<'a, S, UpdateFromSet, T, Cons<F, Nil>>
Adds FROM source, making another table’s columns available to
WHERE and RETURNING.
§Examples
use drizzle::core::expr::eq;
let query = db
.update(user)
.set(UpdateUser::default().with_name("Author"))
.from(post)
.r#where(eq(post.author_id, user.id));
assert_eq!(
query.to_sql().sql(),
r#"UPDATE "users" SET "name" = $1 FROM "posts" WHERE "posts"."author_id" = "users"."id""#
);Sourcepub fn where<E, ScopeProof>(
self,
condition: E,
) -> UpdateBuilder<'a, S, UpdateWhereSet, T>where
E: ExprSources + Expr<'a, PostgresValue<'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, PostgresValue<'a>>,
E::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
E::SQLType: BooleanLike,
Adds a WHERE condition; only matching rows are updated.
The condition may only use columns of the updated table; to use other
tables, add from first.
Sourcepub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> UpdateBuilder<'a, S, UpdateReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
pub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> UpdateBuilder<'a, S, UpdateReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, Nil>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
Adds RETURNING columns, so the statement returns the updated rows.
Source§impl<'a, S, T, M> QueryBuilder<'a, S, UpdateFromSet, T, M>
impl<'a, S, T, M> QueryBuilder<'a, S, UpdateFromSet, T, M>
Sourcepub fn where<E, ScopeProof>(
self,
condition: E,
) -> UpdateBuilder<'a, S, UpdateWhereSet, T, M>where
E: ExprSources + Expr<'a, PostgresValue<'a>>,
E::Sources: SourcesIn<Cons<T, M>, ScopeProof>,
E::SQLType: BooleanLike,
pub fn where<E, ScopeProof>(
self,
condition: E,
) -> UpdateBuilder<'a, S, UpdateWhereSet, T, M>where
E: ExprSources + Expr<'a, PostgresValue<'a>>,
E::Sources: SourcesIn<Cons<T, M>, ScopeProof>,
E::SQLType: BooleanLike,
Adds a WHERE condition, which may use the updated table and the FROM source.
Sourcepub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> UpdateBuilder<'a, S, UpdateReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, M>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
pub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> UpdateBuilder<'a, S, UpdateReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, M>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
Adds RETURNING columns after FROM.
Source§impl<'a, S, T, M> QueryBuilder<'a, S, UpdateWhereSet, T, M>
impl<'a, S, T, M> QueryBuilder<'a, S, UpdateWhereSet, T, M>
Sourcepub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> UpdateBuilder<'a, S, UpdateReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, M>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
pub fn returning<Columns, ScopeProof>(
self,
columns: Columns,
) -> UpdateBuilder<'a, S, UpdateReturningSet, T, Scoped<<Columns as IntoSelectTarget>::Marker, Cons<T, Nil>>, <<Columns as IntoSelectTarget>::Marker as ResolveRow<T>>::Row>where
Columns: ExprSources + ToSQL<'a, PostgresValue<'a>> + IntoSelectTarget,
Columns::Sources: SourcesIn<Cons<T, M>, ScopeProof>,
Columns::Marker: ResolveRow<T>,
Adds RETURNING columns after WHERE.
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 statement.
The text is wrapped in /* ... */. Any /* or */ in the input is
neutralised so it cannot end the comment early. Empty text adds nothing.
§Examples
let query = db.select(user.id).from(user).comment("list-users");
assert_eq!(query.to_sql().sql(), r#"/*list-users*/ SELECT "users"."id" FROM "users""#);Prepends a key-value sqlcommenter comment to the statement.
Each pair renders as key='value', URL-encoded. Pairs are sorted by
key, joined with , and wrapped in /* ... */. Pairs with an empty
value are skipped; if none remain, nothing is added.
§Examples
let query = db
.select(user.id)
.from(user)
.comment_tags([("route", "/users"), ("action", "list")]);
let sql = query.to_sql().sql();
assert!(sql.starts_with("/*action='list',route='%2Fusers'*/"));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 schema S.
§Examples
let db = QueryBuilder::new::<Schema>();
let query = db.select(()).from(user);
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."id", "users"."name", "users"."email" FROM "users""#
);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 of the given columns.
Pass one column or expression, a tuple of them, or () for every
column of the FROM table. Continue with .from(table).
§Examples
use drizzle::core::expr::eq;
let query = db
.select((user.name, post.title))
.from(user)
.join((post, eq(post.author_id, user.id)));
assert_eq!(
query.to_sql().sql(),
r#"SELECT "users"."name", "posts"."title" FROM "users" JOIN "posts" ON "posts"."author_id" = "users"."id""#
);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.
§Examples
let query = db.select_distinct(user.name).from(user);
assert_eq!(query.to_sql().sql(), r#"SELECT DISTINCT "users"."name" FROM "users""#);Sourcepub fn select_distinct_on<On, Columns>(
&self,
on: On,
columns: Columns,
) -> SelectBuilder<'a, Schema, SelectInitial, (), Columns::Marker>
pub fn select_distinct_on<On, Columns>( &self, on: On, columns: Columns, ) -> SelectBuilder<'a, Schema, SelectInitial, (), Columns::Marker>
Starts a SELECT DISTINCT ON (...), which keeps one row per distinct
value of on.
The first row of each group wins, so add an order_by that starts
with the on columns to choose which row is kept.
§Examples
let query = db
.select_distinct_on(user.email, (user.id, user.email))
.from(user)
.order_by(user.email);
assert_eq!(
query.to_sql().sql(),
r#"SELECT DISTINCT ON ("users"."email") "users"."id", "users"."email" FROM "users" ORDER BY "users"."email""#
);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 the main SELECT after WITH .... See QueryBuilder::with.
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 the main SELECT DISTINCT after WITH ....
Sourcepub fn select_distinct_on<On, Columns>(
&self,
on: On,
columns: Columns,
) -> SelectBuilder<'a, Schema, SelectInitial, (), Columns::Marker>
pub fn select_distinct_on<On, Columns>( &self, on: On, columns: Columns, ) -> SelectBuilder<'a, Schema, SelectInitial, (), Columns::Marker>
Starts the main SELECT DISTINCT ON (...) after WITH ....
Sourcepub fn insert<Table>(
&self,
table: Table,
) -> InsertBuilder<'a, Schema, InsertInitial, Table>where
Table: PostgresTable<'a>,
pub fn insert<Table>(
&self,
table: Table,
) -> InsertBuilder<'a, Schema, InsertInitial, Table>where
Table: PostgresTable<'a>,
Starts the main INSERT after WITH ....
Sourcepub fn update<Table>(
&self,
table: Table,
) -> UpdateBuilder<'a, Schema, UpdateInitial, Table>where
Table: PostgresTable<'a>,
pub fn update<Table>(
&self,
table: Table,
) -> UpdateBuilder<'a, Schema, UpdateInitial, Table>where
Table: PostgresTable<'a>,
Starts the main UPDATE after WITH ....
Sourcepub fn delete<Table>(
&self,
table: Table,
) -> DeleteBuilder<'a, Schema, DeleteInitial, Table>where
Table: PostgresTable<'a>,
pub fn delete<Table>(
&self,
table: Table,
) -> DeleteBuilder<'a, Schema, DeleteInitial, Table>where
Table: PostgresTable<'a>,
Starts the main DELETE after WITH ....
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 list.
Source§impl<'a, Schema> QueryBuilder<'a, Schema, BuilderInit>
impl<'a, Schema> QueryBuilder<'a, Schema, BuilderInit>
Sourcepub fn insert<Table>(
&self,
table: Table,
) -> InsertBuilder<'a, Schema, InsertInitial, Table>where
Table: PostgresTable<'a>,
pub fn insert<Table>(
&self,
table: Table,
) -> InsertBuilder<'a, Schema, InsertInitial, Table>where
Table: PostgresTable<'a>,
Starts an INSERT INTO table. Continue with .values(...) or .select(...).
§Examples
let query = db.insert(user).values([InsertUser::new("Alice")]);
assert_eq!(query.to_sql().sql(), r#"INSERT INTO "users" ("name") VALUES ($1)"#);Sourcepub fn update<Table>(
&self,
table: Table,
) -> UpdateBuilder<'a, Schema, UpdateInitial, Table>where
Table: PostgresTable<'a>,
pub fn update<Table>(
&self,
table: Table,
) -> UpdateBuilder<'a, Schema, UpdateInitial, Table>where
Table: PostgresTable<'a>,
Starts an UPDATE table. Continue with .set(...).
§Examples
use drizzle::core::expr::eq;
let query = db
.update(user)
.set(UpdateUser::default().with_name("Bob"))
.r#where(eq(user.id, 1));
assert_eq!(
query.to_sql().sql(),
r#"UPDATE "users" SET "name" = $1 WHERE "users"."id" = $2"#
);Sourcepub fn delete<Table>(
&self,
table: Table,
) -> DeleteBuilder<'a, Schema, DeleteInitial, Table>where
Table: PostgresTable<'a>,
pub fn delete<Table>(
&self,
table: Table,
) -> DeleteBuilder<'a, Schema, DeleteInitial, Table>where
Table: PostgresTable<'a>,
Starts a DELETE FROM table.
Without .where(...) the statement deletes every row.
§Examples
use drizzle::core::expr::gt;
let query = db.delete(user).r#where(gt(user.id, 10));
assert_eq!(query.to_sql().sql(), r#"DELETE FROM "users" WHERE "users"."id" > $1"#);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 from a common table expression (CTE).
Build the CTE with SelectBuilder::into_cte::<Tag>(), then reference
it in the main statement through its .table field. Chain more
.with(...) calls to add more CTEs.
§Examples
use drizzle::core::expr::gt;
struct Recent;
impl drizzle::core::Tag for Recent {
const NAME: &'static str = "recent";
}
let recent = db
.select((user.id, user.name))
.from(user)
.r#where(gt(user.id, 100))
.into_cte::<Recent>();
let r = recent.table;
let query = db.with(&recent).select(r.name).from(&recent);
assert_eq!(
query.to_sql().sql(),
r#"WITH "recent" AS (SELECT "users"."id", "users"."name" FROM "users" WHERE "users"."id" > $1) SELECT "recent"."name" FROM "recent""#
);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: Default, State: Default, Table: Default, Marker: Default, Row: Default, Grouped: Default> Default for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
impl<'a, Schema: Default, State: Default, Table: Default, Marker: Default, Row: Default, Grouped: Default> Default for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
Source§impl<'a, Schema, State, Table, Marker, Row, Grouped> ToSQL<'a, PostgresValue<'a>> for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
impl<'a, Schema, State, Table, Marker, Row, Grouped> ToSQL<'a, PostgresValue<'a>> for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
Auto Trait Implementations§
impl<'a, Schema = (), State = (), Table = (), Marker = (), Row = (), Grouped = ()> !RefUnwindSafe for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
impl<'a, Schema = (), State = (), Table = (), Marker = (), Row = (), Grouped = ()> !UnwindSafe for QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>
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> 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,
Blanket Implementations§
Source§impl<'a, E> ArrayExprExt<'a> for Ewhere
E: Expr<'a, PostgresValue<'a>>,
impl<'a, E> ArrayExprExt<'a> for Ewhere
E: Expr<'a, PostgresValue<'a>>,
Source§fn array_contains<R>(
self,
other: R,
) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
fn array_contains<R>( self, other: R, ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
Source§fn array_contained<R>(
self,
other: R,
) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
fn array_contained<R>( self, other: R, ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
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.Source§impl<'a, E> JsonExprExt<'a> for Ewhere
E: Expr<'a, PostgresValue<'a>>,
impl<'a, E> JsonExprExt<'a> for Ewhere
E: Expr<'a, PostgresValue<'a>>,
Source§fn json_get(
self,
key: &'a str,
) -> SQLExpr<'a, PostgresValue<'a>, <Self::SQLType as JsonType>::Field, Null, Self::Aggregate, Self::Sources>
fn json_get( self, key: &'a str, ) -> SQLExpr<'a, PostgresValue<'a>, <Self::SQLType as JsonType>::Field, Null, Self::Aggregate, Self::Sources>
->), keeping the JSON type. See json_get.Source§fn json_get_idx(
self,
index: i32,
) -> SQLExpr<'a, PostgresValue<'a>, <Self::SQLType as JsonType>::Field, Null, Self::Aggregate, Self::Sources>
fn json_get_idx( self, index: i32, ) -> SQLExpr<'a, PostgresValue<'a>, <Self::SQLType as JsonType>::Field, Null, Self::Aggregate, Self::Sources>
->), keeping the JSON type. See json_get_idx.Source§fn json_get_text(
self,
key: &'a str,
) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Self::Aggregate, Self::Sources>
fn json_get_text( self, key: &'a str, ) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Self::Aggregate, Self::Sources>
Source§fn json_get_text_idx(
self,
index: i32,
) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Self::Aggregate, Self::Sources>
fn json_get_text_idx( self, index: i32, ) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Self::Aggregate, Self::Sources>
Source§fn json_get_path(
self,
path: &'a str,
) -> SQLExpr<'a, PostgresValue<'a>, <Self::SQLType as JsonType>::Field, Null, Self::Aggregate, Self::Sources>
fn json_get_path( self, path: &'a str, ) -> SQLExpr<'a, PostgresValue<'a>, <Self::SQLType as JsonType>::Field, Null, Self::Aggregate, Self::Sources>
#>), keeping the JSON type. See json_get_path.