Struct query_structure::QueryArguments
source · pub struct QueryArguments {
pub model: Model,
pub cursor: Option<SelectionResult>,
pub take: Option<i64>,
pub skip: Option<i64>,
pub filter: Option<Filter>,
pub order_by: Vec<OrderBy>,
pub distinct: Option<FieldSelection>,
pub ignore_skip: bool,
pub ignore_take: bool,
pub relation_load_strategy: Option<RelationLoadStrategy>,
}
Expand description
QueryArguments
define various constraints queried data should fulfill:
cursor
,take
,skip
page through the data.filter
scopes the data by defining conditions (akin toWHERE
in SQL).order_by
defines the ordering of records, from most high to low precedence.distinct
designates the fields on which the records should be distinct.- The
ignore_*
flags are a temporary bandaid to tell the connector to do not include certain constraints when building queries, because the core is already performing these action in a different manner (e.g. in-memory on all records).
A query argument struct is always valid over a single model only, meaning that all data referenced in a single query argument instance is always refering to data of a single model (e.g. the cursor projection, distinct projection, orderby, …).
Fields§
§model: Model
§cursor: Option<SelectionResult>
§take: Option<i64>
§skip: Option<i64>
§filter: Option<Filter>
§order_by: Vec<OrderBy>
§distinct: Option<FieldSelection>
§ignore_skip: bool
§ignore_take: bool
§relation_load_strategy: Option<RelationLoadStrategy>
Implementations§
source§impl QueryArguments
impl QueryArguments
pub fn new(model: Model) -> Self
pub fn do_nothing(&self) -> bool
sourcepub fn requires_inmemory_processing(&self) -> bool
pub fn requires_inmemory_processing(&self) -> bool
We can’t execute all operations on the DB level reliably. This is a marker that generally expresses whether or not a set of records can be retrieved by the connector or if it requires the query engine to fetch a raw set of records and perform certain operations itself, in-memory.
pub fn requires_inmemory_distinct(&self) -> bool
sourcepub fn contains_unstable_cursor(&self) -> bool
pub fn contains_unstable_cursor(&self) -> bool
An unstable cursor is a cursor that is used in conjunction with an unstable (non-unique) combination of orderBys.
sourcepub fn contains_null_cursor(&self) -> bool
pub fn contains_null_cursor(&self) -> bool
A null cursor is a cursor that is used in conjunction with a nullable order by (i.e. a field is optional).
sourcepub fn is_stable_ordering(&self) -> bool
pub fn is_stable_ordering(&self) -> bool
Checks if the orderBy provided is guaranteeing a stable ordering of records for the model. For that purpose we need to distinguish orderings on the source model, i.e. the model that we’re sorting on the top level (where orderBys are located that are done without relations) and orderings that require a relation or composite hop. Scalar orderings that require a hop are only guaranteed stable ordering if they are strictly over 1:1. As soon as there’s a m:1 (or m:n for later implementations) hop involved a unique on the to-one side can’t be considered unique anymore for the purpose of ordering records, as many left hand records (the many side) can have the one side. A simple example would be a User <> Post relation where a post can have only one author but an author (User) can have many posts. If posts are ordered by related author id, then we can’t reliably order posts, as the following can happen:
post_id, post_title, author_id
1 post1 1
2 post2 1
3 post3 2
So even though the id is unique, it’s not guaranteeing a stable ordering in the context of orderBy here.
Returns:
true
, if:- no orderings are done, or …
- at least one unique field is present on the source model
orderBy
, or … - source model contains a combination of fields that is marked as unique, or …
- an orderBy hop contains a unique and is done solely over 1:1 relations.
false
otherwise.
pub fn take_abs(&self) -> Option<i64>
pub fn has_unbatchable_ordering(&self) -> bool
pub fn has_unbatchable_filters(&self) -> bool
pub fn should_batch(&self, chunk_size: usize) -> bool
pub fn batched(self, chunk_size: usize) -> Vec<Self>
pub fn model(&self) -> &Model
Trait Implementations§
source§impl Clone for QueryArguments
impl Clone for QueryArguments
source§fn clone(&self) -> QueryArguments
fn clone(&self) -> QueryArguments
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for QueryArguments
impl Debug for QueryArguments
source§impl Hash for QueryArguments
impl Hash for QueryArguments
source§impl PartialEq for QueryArguments
impl PartialEq for QueryArguments
source§fn eq(&self, other: &QueryArguments) -> bool
fn eq(&self, other: &QueryArguments) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for QueryArguments
impl StructuralEq for QueryArguments
impl StructuralPartialEq for QueryArguments
Auto Trait Implementations§
impl !RefUnwindSafe for QueryArguments
impl Send for QueryArguments
impl Sync for QueryArguments
impl Unpin for QueryArguments
impl !UnwindSafe for QueryArguments
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CallHasher for Twhere
T: Hash + ?Sized,
impl<T> CallHasher for Twhere T: Hash + ?Sized,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.