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 to WHERE 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

source

pub fn new(model: Model) -> Self

source

pub fn do_nothing(&self) -> bool

source

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.

source

pub fn requires_inmemory_distinct(&self) -> bool

source

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.

source

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).

source

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.
source

pub fn take_abs(&self) -> Option<i64>

source

pub fn has_unbatchable_ordering(&self) -> bool

source

pub fn has_unbatchable_filters(&self) -> bool

source

pub fn should_batch(&self, chunk_size: usize) -> bool

source

pub fn batched(self, chunk_size: usize) -> Vec<Self>

source

pub fn model(&self) -> &Model

Trait Implementations§

source§

impl Clone for QueryArguments

source§

fn clone(&self) -> QueryArguments

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 Debug for QueryArguments

source§

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

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

impl<T> From<(Zipper<ModelId>, T)> for QueryArgumentswhere T: Into<Filter>,

source§

fn from(model_filter: (Model, T)) -> Self

Converts to this type from the input type.
source§

impl Hash for QueryArguments

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for QueryArguments

source§

fn eq(&self, other: &QueryArguments) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for QueryArguments

source§

impl StructuralEq for QueryArguments

source§

impl StructuralPartialEq for QueryArguments

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

source§

fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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 Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V