diesel::query_builder

Struct Tablesample

Source
pub struct Tablesample<S, TSM>
where TSM: TablesampleMethod,
{ /* private fields */ }
Available on crate feature postgres_backend only.
Expand description

Represents a query with a TABLESAMPLE clause.

Implementations§

Source§

impl<S, TSM> Tablesample<S, TSM>
where TSM: TablesampleMethod,

Source

pub fn with_seed(self, seed: f64) -> Tablesample<S, TSM>

This method allows you to specify the random number generator seed to use in the sampling method. This allows you to obtain repeatable results.

Trait Implementations§

Source§

impl<S, TSM> AsQuery for Tablesample<S, TSM>
where S: Table + Clone, TSM: TablesampleMethod, <S as QuerySource>::DefaultSelection: ValidGrouping<()> + SelectableExpression<Tablesample<S, TSM>>,

Source§

type SqlType = <<Tablesample<S, TSM> as QuerySource>::DefaultSelection as Expression>::SqlType

The SQL type of Self::Query
Source§

type Query = SelectStatement<FromClause<Tablesample<S, TSM>>>

What kind of query does this type represent?
Source§

fn as_query(self) -> Self::Query

Converts a type which semantically represents a SQL query into the actual query being executed. See the trait level docs for more.
Source§

impl<S: Clone, TSM> Clone for Tablesample<S, TSM>
where TSM: TablesampleMethod + Clone,

Source§

fn clone(&self) -> Tablesample<S, TSM>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S: Debug, TSM> Debug for Tablesample<S, TSM>
where TSM: TablesampleMethod + Debug,

Source§

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

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

impl<S, TSM> QueryFragment<Pg> for Tablesample<S, TSM>
where S: QueryFragment<Pg>, TSM: TablesampleMethod,

Source§

fn walk_ast<'b>(&'b self, out: AstPass<'_, 'b, Pg>) -> QueryResult<()>

Walk over this QueryFragment for all passes. Read more
Source§

fn to_sql(&self, out: &mut DB::QueryBuilder, backend: &DB) -> QueryResult<()>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Converts this QueryFragment to its SQL representation. Read more
Source§

fn collect_binds<'b>( &'b self, out: &mut DB::BindCollector<'b>, metadata_lookup: &mut DB::MetadataLookup, backend: &'b DB, ) -> QueryResult<()>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Serializes all bind parameters in this query. Read more
Source§

fn is_safe_to_cache_prepared(&self, backend: &DB) -> QueryResult<bool>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Is this query safe to store in the prepared statement cache? Read more
Source§

fn is_noop(&self, backend: &DB) -> QueryResult<bool>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Does walking this AST have any effect?
Source§

impl<S, TSM> QueryId for Tablesample<S, TSM>
where S: QueryId, TSM: TablesampleMethod,

Source§

const HAS_STATIC_QUERY_ID: bool = false

Can the SQL generated by Self be uniquely identified by its type? Read more
Source§

type QueryId = ()

A type which uniquely represents Self in a SQL query. Read more
Source§

fn query_id() -> Option<TypeId>

Returns the type id of Self::QueryId if Self::HAS_STATIC_QUERY_ID. Returns None otherwise. Read more
Source§

impl<S, TSM> QuerySource for Tablesample<S, TSM>
where S: Table + Clone, TSM: TablesampleMethod, <S as QuerySource>::DefaultSelection: ValidGrouping<()> + SelectableExpression<Tablesample<S, TSM>>,

Source§

type FromClause = Tablesample<S, TSM>

The type returned by from_clause
Source§

type DefaultSelection = <S as QuerySource>::DefaultSelection

The type returned by default_selection
Source§

fn from_clause(&self) -> Self::FromClause

The actual FROM clause of this type. This is typically only called in QueryFragment implementations.
Source§

fn default_selection(&self) -> Self::DefaultSelection

The default select clause of this type, which should be used if no select clause was explicitly specified. This should always be a tuple of all the desired columns, not star
Source§

impl<S, TSM> Table for Tablesample<S, TSM>

Source§

type PrimaryKey = <S as Table>::PrimaryKey

The type returned by primary_key
Source§

type AllColumns = <S as Table>::AllColumns

The type returned by all_columns
Source§

fn primary_key(&self) -> Self::PrimaryKey

Returns the primary key of this table. Read more
Source§

fn all_columns() -> Self::AllColumns

Returns a tuple of all columns belonging to this table.
Source§

impl<S: Copy, TSM> Copy for Tablesample<S, TSM>
where TSM: TablesampleMethod + Copy,

Source§

impl<S, T, TSM> JoinTo<T> for Tablesample<S, TSM>
where S: JoinTo<T> + Table, T: Table, TSM: TablesampleMethod,

Auto Trait Implementations§

§

impl<S, TSM> Freeze for Tablesample<S, TSM>
where S: Freeze,

§

impl<S, TSM> RefUnwindSafe for Tablesample<S, TSM>

§

impl<S, TSM> Send for Tablesample<S, TSM>
where S: Send, TSM: Send,

§

impl<S, TSM> Sync for Tablesample<S, TSM>
where S: Sync, TSM: Sync,

§

impl<S, TSM> Unpin for Tablesample<S, TSM>
where S: Unpin, TSM: Unpin,

§

impl<S, TSM> UnwindSafe for Tablesample<S, TSM>
where S: UnwindSafe, TSM: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T1, T2> AppearsInFromClause<T2> for T1
where T1: TableNotEqual<T2> + Table, T2: Table,

Source§

type Count = Never

How many times does Self appear in QS?
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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

impl<T> CombineDsl for T
where T: Table,

Source§

type Query = <T as AsQuery>::Query

What kind of query does this type represent?
Source§

fn union<Rhs>( self, rhs: Rhs, ) -> CombinationClause<Union, Distinct, <T as CombineDsl>::Query, <Rhs as AsQuery>::Query>
where Rhs: AsQuery<SqlType = <<T as CombineDsl>::Query as Query>::SqlType>,

Combine two queries using a SQL UNION Read more
Source§

fn union_all<Rhs>( self, rhs: Rhs, ) -> CombinationClause<Union, All, <T as CombineDsl>::Query, <Rhs as AsQuery>::Query>
where Rhs: AsQuery<SqlType = <<T as CombineDsl>::Query as Query>::SqlType>,

Combine two queries using a SQL UNION ALL
Source§

fn intersect<Rhs>( self, rhs: Rhs, ) -> CombinationClause<Intersect, Distinct, <T as CombineDsl>::Query, <Rhs as AsQuery>::Query>
where Rhs: AsQuery<SqlType = <<T as CombineDsl>::Query as Query>::SqlType>,

Combine two queries using a SQL INTERSECT
Source§

fn intersect_all<Rhs>( self, rhs: Rhs, ) -> CombinationClause<Intersect, All, <T as CombineDsl>::Query, <Rhs as AsQuery>::Query>
where Rhs: AsQuery<SqlType = <<T as CombineDsl>::Query as Query>::SqlType>,

Combine two queries using a SQL INTERSECT ALL
Source§

fn except<Rhs>( self, rhs: Rhs, ) -> CombinationClause<Except, Distinct, <T as CombineDsl>::Query, <Rhs as AsQuery>::Query>
where Rhs: AsQuery<SqlType = <<T as CombineDsl>::Query as Query>::SqlType>,

Combine two queries using a SQL EXCEPT
Source§

fn except_all<Rhs>( self, rhs: Rhs, ) -> CombinationClause<Except, All, <T as CombineDsl>::Query, <Rhs as AsQuery>::Query>
where Rhs: AsQuery<SqlType = <<T as CombineDsl>::Query as Query>::SqlType>,

Combine two queries using a SQL EXCEPT ALL
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Conn, DB, T> ExecuteDsl<Conn, DB> for T
where Conn: Connection<Backend = DB>, DB: Backend, T: QueryFragment<DB> + QueryId,

Source§

fn execute(query: T, conn: &mut Conn) -> Result<usize, Error>

Execute this command
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> AsExprOf<Self, T>

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> JoinOnDsl for T
where T: QuerySource,

Source§

fn on<On>(self, on: On) -> On<Self, On>

See the trait documentation.
Source§

impl<T> OnlyDsl for T
where T: Table,

Source§

fn only(self) -> Only<Self>

Available on crate feature postgres_backend only.
See the trait-level docs.
Source§

impl<T> QueryDsl for T
where T: Table,

Source§

fn distinct(self) -> Distinct<Self>
where Self: DistinctDsl,

Adds the DISTINCT keyword to a query. Read more
Source§

fn distinct_on<Expr>(self, expr: Expr) -> DistinctOn<Self, Expr>
where Self: DistinctOnDsl<Expr>,

Available on crate feature postgres_backend only.
Adds the DISTINCT ON clause to a query. Read more
Source§

fn select<Selection>(self, selection: Selection) -> Select<Self, Selection>
where Selection: Expression, Self: SelectDsl<Selection>,

Adds a SELECT clause to the query. Read more
Source§

fn count(self) -> Select<Self, CountStar>
where Self: SelectDsl<CountStar>,

Get the count of a query. This is equivalent to .select(count_star()) Read more
Source§

fn inner_join<Rhs>(self, rhs: Rhs) -> InnerJoin<Self, Rhs>
where Self: JoinWithImplicitOnClause<Rhs, Inner>,

Join two tables using a SQL INNER JOIN. Read more
Source§

fn left_outer_join<Rhs>(self, rhs: Rhs) -> LeftJoin<Self, Rhs>
where Self: JoinWithImplicitOnClause<Rhs, LeftOuter>,

Join two tables using a SQL LEFT OUTER JOIN. Read more
Source§

fn left_join<Rhs>(self, rhs: Rhs) -> LeftJoin<Self, Rhs>
where Self: JoinWithImplicitOnClause<Rhs, LeftOuter>,

Alias for left_outer_join.
Source§

fn filter<Predicate>(self, predicate: Predicate) -> Filter<Self, Predicate>
where Self: FilterDsl<Predicate>,

Adds to the WHERE clause of a query. Read more
Source§

fn or_filter<Predicate>(self, predicate: Predicate) -> OrFilter<Self, Predicate>
where Self: OrFilterDsl<Predicate>,

Adds to the WHERE clause of a query using OR Read more
Source§

fn find<PK>(self, id: PK) -> Find<Self, PK>
where Self: FindDsl<PK>,

Attempts to find a single record from the given table by primary key. Read more
Source§

fn order<Expr>(self, expr: Expr) -> Order<Self, Expr>
where Expr: Expression, Self: OrderDsl<Expr>,

Sets the order clause of a query. Read more
Source§

fn order_by<Expr>(self, expr: Expr) -> OrderBy<Self, Expr>
where Expr: Expression, Self: OrderDsl<Expr>,

Alias for order
Source§

fn then_order_by<Order>(self, order: Order) -> ThenOrderBy<Self, Order>
where Self: ThenOrderDsl<Order>,

Appends to the ORDER BY clause of this SQL query. Read more
Source§

fn limit(self, limit: i64) -> Limit<Self>
where Self: LimitDsl,

Sets the limit clause of the query. Read more
Source§

fn offset(self, offset: i64) -> Offset<Self>
where Self: OffsetDsl,

Sets the offset clause of the query. Read more
Source§

fn group_by<GB>(self, group_by: GB) -> GroupBy<Self, GB>
where GB: Expression, Self: GroupByDsl<GB>,

Sets the group by clause of a query. Read more
Source§

fn having<Predicate>(self, predicate: Predicate) -> Having<Self, Predicate>
where Self: HavingDsl<Predicate>,

Adds to the HAVING clause of a query. Read more
Source§

fn for_update(self) -> ForUpdate<Self>
where Self: LockingDsl<ForUpdate>,

Adds FOR UPDATE to the end of the select statement. Read more
Source§

fn for_no_key_update(self) -> ForNoKeyUpdate<Self>
where Self: LockingDsl<ForNoKeyUpdate>,

Adds FOR NO KEY UPDATE to the end of the select statement. Read more
Source§

fn for_share(self) -> ForShare<Self>
where Self: LockingDsl<ForShare>,

Adds FOR SHARE to the end of the select statement. Read more
Source§

fn for_key_share(self) -> ForKeyShare<Self>
where Self: LockingDsl<ForKeyShare>,

Adds FOR KEY SHARE to the end of the select statement. Read more
Source§

fn skip_locked(self) -> SkipLocked<Self>
where Self: ModifyLockDsl<SkipLocked>,

Adds SKIP LOCKED to the end of a FOR UPDATE clause. Read more
Source§

fn no_wait(self) -> NoWait<Self>
where Self: ModifyLockDsl<NoWait>,

Adds NOWAIT to the end of a FOR UPDATE clause. Read more
Source§

fn into_boxed<'a, DB>(self) -> IntoBoxed<'a, Self, DB>
where DB: Backend, Self: BoxedDsl<'a, DB>,

Boxes the pieces of a query into a single type. Read more
Source§

fn single_value(self) -> SingleValue<Self>
where Self: SingleValueDsl,

Wraps this select statement in parenthesis, allowing it to be used as an expression. Read more
Source§

fn nullable(self) -> NullableSelect<Self>
where Self: SelectNullableDsl,

Coerce the SQL type of the select clause to it’s nullable equivalent. Read more
Source§

impl<T, DB> QueryFragmentForCachedStatement<DB> for T
where DB: Backend, <DB as Backend>::QueryBuilder: Default, T: QueryFragment<DB>,

Source§

fn construct_sql(&self, backend: &DB) -> Result<String, Error>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Convert the query fragment into a SQL string for the given backend
Source§

fn is_safe_to_cache_prepared(&self, backend: &DB) -> Result<bool, Error>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Check whether it’s safe to cache the query
Source§

impl<T, Conn> RunQueryDsl<Conn> for T
where T: Table,

Source§

fn execute(self, conn: &mut Conn) -> QueryResult<usize>
where Conn: Connection, Self: ExecuteDsl<Conn>,

Executes the given command, returning the number of rows affected. Read more
Source§

fn load<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>>
where Self: LoadQuery<'query, Conn, U>,

Executes the given query, returning a Vec with the returned rows. Read more
Source§

fn load_iter<'conn, 'query: 'conn, U, B>( self, conn: &'conn mut Conn, ) -> QueryResult<Self::RowIter<'conn>>
where U: 'conn, Self: LoadQuery<'query, Conn, U, B> + 'conn,

Executes the given query, returning an Iterator with the returned rows. Read more
Source§

fn get_result<'query, U>(self, conn: &mut Conn) -> QueryResult<U>
where Self: LoadQuery<'query, Conn, U>,

Runs the command, and returns the affected row. Read more
Source§

fn get_results<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>>
where Self: LoadQuery<'query, Conn, U>,

Runs the command, returning an Vec with the affected rows. Read more
Source§

fn first<'query, U>(self, conn: &mut Conn) -> QueryResult<U>
where Self: LimitDsl, Limit<Self>: LoadQuery<'query, Conn, U>,

Attempts to load a single record. Read more
Source§

impl<T> TablesampleDsl for T
where T: Table,

Source§

fn tablesample_bernoulli( self, portion: i16, ) -> Tablesample<Self, BernoulliMethod>

Available on crate feature postgres_backend only.
See the trait-level docs.
Source§

fn tablesample_system(self, portion: i16) -> Tablesample<Self, SystemMethod>

Available on crate feature postgres_backend only.
See the trait-level docs.
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T