Skip to main content

IntoScope

Trait IntoScope 

Source
pub trait IntoScope<M> {
    // Required method
    fn into_scope(self) -> Statement<List<M>>;
}
Expand description

Convert a query into a scope statement over model M.

IntoScope<M> captures “this is a query targeting model M, regardless of cardinality.” It admits the three forms a relation accessor can produce — Query<List<M>>, Query<Option<M>>, and Query<M> — and lowers each to a Statement<List<M>> suitable for use as an insert scope (see Insert::set_scope).

Compare to IntoStatement, which preserves the query’s returning type and so distinguishes the three forms above. IntoScope erases that distinction, since the scope of an insert only cares about which rows the query addresses, not how many it would return on execution.

For Query<Option<M>> and Query<M> — produced by Query::first and Query::one respectively — the single flag and the paired LIMIT 1 added by those narrowing methods are cleared, since Statement<List<M>> would otherwise be self-contradictory (“a list that returns one row”).

Required Methods§

Source

fn into_scope(self) -> Statement<List<M>>

Lower self into a Statement<List<M>> for use as an insert scope.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<M> IntoScope<M> for Association<List<M>>
where M: Model,

Source§

impl<M> IntoScope<M> for Association<M>
where M: Model,

Source§

impl<M> IntoScope<M> for Query<List<M>>

Source§

impl<M> IntoScope<M> for Query<M>

Source§

impl<M> IntoScope<M> for Query<Option<M>>