pub struct ModelSelect<M: View> { /* private fields */ }Expand description
A model SELECT: the dialect statement plus the extension payloads the
query carries — hooks, preload mapper mods, then-loaders.
Still a Query: build() hands back the same (String, Vec<Value>)
escape hatch as everything else, and the raw Execute verbs keep working.
The model verbs — all, one,
optional — are the path that also runs the
extensions, reading them back through QueryExtensions, which this type
implements with the pinned payload types.
Layer 1 interop: the wrapper implements every Has* clause trait its
statement implements (see delegate.rs), so shared dialect mods
(select::limit(20), select::where_("raw sql"), joins, CTEs, …) apply to
it directly, in the same tuple as typed filters. Statement-specific mods go
through apply.
Implementations§
Source§impl<M: View> ModelSelect<M>
impl<M: View> ModelSelect<M>
Sourcepub fn apply(&mut self, mods: impl Mod<M::Select>)
pub fn apply(&mut self, mods: impl Mod<M::Select>)
Apply mods written against the concrete dialect statement — the escape
hatch for the statement-specific ones (psql’s select::distinct())
that are not generic over a Has* trait and so cannot land on the
wrapper directly.
Sourcepub fn add_hook(&mut self, hook: ExecHook)
pub fn add_hook(&mut self, hook: ExecHook)
Attach a pre-query hook. Runs on the caller’s executor, before the statement, in attachment order.
Sourcepub fn add_mapper_mod(&mut self, mapper_mod: MapperMod<M::Row>)
pub fn add_mapper_mod(&mut self, mapper_mod: MapperMod<M::Row>)
Attach a mapper mod — generated preload mods call this.
Sourcepub fn add_loader(&mut self, loader: Loader<M::Row>)
pub fn add_loader(&mut self, loader: Loader<M::Row>)
Attach a then-loader — generated then-load mods call this.
Sourcepub async fn all(&self, db: &dyn Executor) -> Result<Vec<M::Row>, ExecError>
pub async fn all(&self, db: &dyn Executor) -> Result<Vec<M::Row>, ExecError>
Every row, mapped, loaded, hooked.
The order is the contract: hooks → the statement (through the same
traced verb funnel as everything else) → base FromRow plus mapper
mods, per row → then-loaders → View::after_select. All of it on
db, so inside db’s transaction when db is one.
Sourcepub async fn one(&self, db: &dyn Executor) -> Result<M::Row, ExecError>
pub async fn one(&self, db: &dyn Executor) -> Result<M::Row, ExecError>
Exactly one row — zero is ExecError::RowNotFound, two is
ExecError::TooManyRows, matching the execution layer’s “one means
one”.
Trait Implementations§
Source§impl<M: View> Debug for ModelSelect<M>
impl<M: View> Debug for ModelSelect<M>
Source§impl<M: View> Expression for ModelSelect<M>
impl<M: View> Expression for ModelSelect<M>
Source§impl<M: View> HasCombines for ModelSelect<M>where
M::Select: HasCombines,
impl<M: View> HasCombines for ModelSelect<M>where
M::Select: HasCombines,
Source§fn combines_mut(&mut self) -> &mut Combines
fn combines_mut(&mut self) -> &mut Combines
Source§impl<M: View> HasFetch for ModelSelect<M>
impl<M: View> HasFetch for ModelSelect<M>
Source§impl<M: View> HasGroupBy for ModelSelect<M>where
M::Select: HasGroupBy,
impl<M: View> HasGroupBy for ModelSelect<M>where
M::Select: HasGroupBy,
Source§fn group_by_mut(&mut self) -> &mut GroupBy
fn group_by_mut(&mut self) -> &mut GroupBy
GROUP BY clause to modify.Source§impl<M: View> HasHaving for ModelSelect<M>
impl<M: View> HasHaving for ModelSelect<M>
Source§fn having_mut(&mut self) -> &mut Having
fn having_mut(&mut self) -> &mut Having
HAVING clause to modify.Source§impl<M: View> HasJoins for ModelSelect<M>
impl<M: View> HasJoins for ModelSelect<M>
Source§impl<M: View> HasLimit for ModelSelect<M>
impl<M: View> HasLimit for ModelSelect<M>
Source§impl<M: View> HasLocks for ModelSelect<M>
impl<M: View> HasLocks for ModelSelect<M>
Source§impl<M: View> HasOffset for ModelSelect<M>
impl<M: View> HasOffset for ModelSelect<M>
Source§fn offset_mut(&mut self) -> &mut Offset
fn offset_mut(&mut self) -> &mut Offset
OFFSET clause to modify.Source§impl<M: View> HasOrderBy for ModelSelect<M>where
M::Select: HasOrderBy,
impl<M: View> HasOrderBy for ModelSelect<M>where
M::Select: HasOrderBy,
Source§fn order_by_mut(&mut self) -> &mut OrderBy
fn order_by_mut(&mut self) -> &mut OrderBy
ORDER BY clause to modify.Source§impl<M: View> HasSelectList for ModelSelect<M>where
M::Select: HasSelectList,
impl<M: View> HasSelectList for ModelSelect<M>where
M::Select: HasSelectList,
Source§fn select_list_mut(&mut self) -> &mut SelectList
fn select_list_mut(&mut self) -> &mut SelectList
Source§impl<M: View> HasTableRef for ModelSelect<M>where
M::Select: HasTableRef,
impl<M: View> HasTableRef for ModelSelect<M>where
M::Select: HasTableRef,
Source§fn table_ref_mut(&mut self) -> &mut TableRef
fn table_ref_mut(&mut self) -> &mut TableRef
Source§impl<M: View> HasWhere for ModelSelect<M>
impl<M: View> HasWhere for ModelSelect<M>
Source§impl<M: View> HasWindows for ModelSelect<M>where
M::Select: HasWindows,
impl<M: View> HasWindows for ModelSelect<M>where
M::Select: HasWindows,
Source§fn windows_mut(&mut self) -> &mut Windows
fn windows_mut(&mut self) -> &mut Windows
WINDOW clause to modify.Source§impl<M: View> HasWith for ModelSelect<M>
impl<M: View> HasWith for ModelSelect<M>
Source§impl<P, C, K> Mod<ModelSelect<P>> for ThenLoad<P, C, K>
impl<P, C, K> Mod<ModelSelect<P>> for ThenLoad<P, C, K>
Source§fn apply(self, q: &mut ModelSelect<P>)
fn apply(self, q: &mut ModelSelect<P>)
q.Source§impl<M: View> Query for ModelSelect<M>
impl<M: View> Query for ModelSelect<M>
Source§impl<M: View> QueryExtensions<Arc<dyn for<'a> Fn(&'a dyn Executor) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'a>> + Sync + Send>, Arc<dyn for<'a> Fn(&'a dyn Executor, &'a mut Vec<<M as View>::Row>) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'a>> + Sync + Send>, Arc<dyn Fn(&mut Row, &mut <M as View>::Row) -> Result<(), ExecError> + Sync + Send>> for ModelSelect<M>
The extension points, answered with the pinned payload types — the
completion of the QueryExtensions wiring core left with type parameters.
impl<M: View> QueryExtensions<Arc<dyn for<'a> Fn(&'a dyn Executor) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'a>> + Sync + Send>, Arc<dyn for<'a> Fn(&'a dyn Executor, &'a mut Vec<<M as View>::Row>) -> Pin<Box<dyn Future<Output = Result<(), ExecError>> + Send + 'a>> + Sync + Send>, Arc<dyn Fn(&mut Row, &mut <M as View>::Row) -> Result<(), ExecError> + Sync + Send>> for ModelSelect<M>
The extension points, answered with the pinned payload types — the
completion of the QueryExtensions wiring core left with type parameters.
Auto Trait Implementations§
impl<M> !RefUnwindSafe for ModelSelect<M>
impl<M> !UnwindSafe for ModelSelect<M>
impl<M> Freeze for ModelSelect<M>
impl<M> Send for ModelSelect<M>
impl<M> Sync for ModelSelect<M>
impl<M> Unpin for ModelSelect<M>
impl<M> UnsafeUnpin for ModelSelect<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<Q> Execute for Q
impl<Q> Execute for Q
Source§fn fetch_all<T>(
&self,
db: &(impl Executor + ?Sized),
) -> impl Future<Output = Result<Vec<T>, ExecError>> + Sendwhere
T: FromRow,
fn fetch_all<T>(
&self,
db: &(impl Executor + ?Sized),
) -> impl Future<Output = Result<Vec<T>, ExecError>> + Sendwhere
T: FromRow,
T.Source§fn fetch_rows(
&self,
db: &(impl Executor + ?Sized),
) -> impl Future<Output = Result<Vec<Row>, ExecError>> + Send
fn fetch_rows( &self, db: &(impl Executor + ?Sized), ) -> impl Future<Output = Result<Vec<Row>, ExecError>> + Send
Source§fn fetch_one<T>(
&self,
db: &(impl Executor + ?Sized),
) -> impl Future<Output = Result<T, ExecError>> + Sendwhere
T: FromRow,
fn fetch_one<T>(
&self,
db: &(impl Executor + ?Sized),
) -> impl Future<Output = Result<T, ExecError>> + Sendwhere
T: FromRow,
ExecError::RowNotFound; a second row
is ExecError::TooManyRows — “one” means one.Source§fn fetch_optional<T>(
&self,
db: &(impl Executor + ?Sized),
) -> impl Future<Output = Result<Option<T>, ExecError>> + Sendwhere
T: FromRow,
fn fetch_optional<T>(
&self,
db: &(impl Executor + ?Sized),
) -> impl Future<Output = Result<Option<T>, ExecError>> + Sendwhere
T: FromRow,
ExecError::TooManyRows.