pub struct FieldSelection { /* private fields */ }
Expand description

A selection of fields from a model.

Implementations§

source§

impl FieldSelection

source

pub fn new(selections: Vec<SelectedField>) -> Self

source

pub fn into_inner(self) -> Vec<SelectedField>

source

pub fn is_superset_of(&self, other: &Self) -> bool

Returns true if self contains (at least) all fields specified in other. false otherwise. Recurses into composite selections and ensures that composite selections are supersets as well.

source

pub fn selections(&self) -> impl Iterator<Item = &SelectedField> + '_

source

pub fn virtuals(&self) -> impl Iterator<Item = &VirtualSelection>

source

pub fn virtuals_owned(&self) -> Vec<VirtualSelection>

source

pub fn without_relations(&self) -> Self

source

pub fn into_virtuals_last(self) -> Self

source

pub fn prisma_names(&self) -> impl Iterator<Item = String> + '_

Returns all Prisma (e.g. schema model field) names of contained fields. Does not recurse into composite selections and only iterates top level fields.

source

pub fn db_names(&self) -> impl Iterator<Item = String> + '_

Returns all database (e.g. column or document field) names of contained fields. Does not recurse into composite selections and only iterates top level fields. Returns db aliases for virtual fields grouped into objects in the query separately, representing results of queries that do not load relations using JOINs.

source

pub fn db_names_grouping_virtuals(&self) -> impl Iterator<Item = String> + '_

Returns all database (e.g. column or document field) names of contained fields. Does not recurse into composite selections and only iterates top level fields. Also does not recurse into the grouped containers for virtual fields, like _count. The names returned by this method correspond to the results of queries that use JSON objects to represent joined relations and relation aggregations.

source

pub fn contains(&self, name: &str) -> bool

Checked if a field of prisma name name is present in this FieldSelection.

source

pub fn get(&self, name: &str) -> Option<&SelectedField>

source

pub fn as_fields(&self) -> Vec<Field>

source

pub fn as_scalar_fields(&self) -> Option<Vec<ScalarFieldRef>>

Checks if self only contains scalar field selections and if so, returns them all in a list. If any other selection is contained, returns None.

source

pub fn assimilate(&self, values: SelectionResult) -> Result<SelectionResult>

Inserts this FieldSelections selections into the given SelectionResult. Assumes caller knows that the exchange can be done, but still errors if lengths mismatch. Additionally performs a type coercion based on the source and destination field types. Resistance is futile.

source

pub fn matches(&self, result: &SelectionResult) -> bool

Checks if a given SelectionResult belongs to this FieldSelection.

source

pub fn union(selections: Vec<Self>) -> Self

Merges all given FieldSelection a set union of all. Each selection is contained exactly once, with the first occurrence of the first field in order from left to right is retained.

/!\ Important assumption: All selections are on the same model.

source

pub fn merge(self, other: FieldSelection) -> FieldSelection

Consumes both FieldSelections to create a new one that contains a union of both. Each selection is contained exactly once, with the first occurrence of the first field in order from left (self) to right (other) is retained. Assumes that both selections reason over the same model.

source

pub fn merge_in_place(&mut self, other: FieldSelection)

source

pub fn type_identifiers_with_arities(&self) -> Vec<(TypeIdentifier, FieldArity)>

Returns type identifiers and arities, treating all virtual fields as separate fields.

source

pub fn type_identifiers_with_arities_grouping_virtuals( &self ) -> Vec<(TypeIdentifier, FieldArity)>

Returns type identifiers and arities, grouping the virtual fields so that the type identifier and arity is returned for the whole object containing multiple virtual fields and not each of those fields separately. This represents the selection in joined queries that use JSON objects for relations and relation aggregations.

source

pub fn relations(&self) -> impl Iterator<Item = &RelationSelection>

source

pub fn into_projection(self) -> ModelProjection

source

pub fn has_virtual_fields(&self) -> bool

Trait Implementations§

source§

impl Clone for FieldSelection

source§

fn clone(&self) -> FieldSelection

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 FieldSelection

source§

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

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

impl Default for FieldSelection

source§

fn default() -> FieldSelection

Returns the “default value” for a type. Read more
source§

impl Display for FieldSelection

source§

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

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

impl From<&FieldSelection> for ModelProjection

[Composites] todo: Temporary converter.

source§

fn from(fs: &FieldSelection) -> Self

Converts to this type from the input type.
source§

impl From<&FieldSelection> for SelectionResult

source§

fn from(fs: &FieldSelection) -> Self

Converts to this type from the input type.
source§

impl From<&SelectionResult> for FieldSelection

source§

fn from(p: &SelectionResult) -> Self

Converts to this type from the input type.
source§

impl From<FieldSelection> for ModelProjection

source§

fn from(fs: FieldSelection) -> Self

Converts to this type from the input type.
source§

impl From<Vec<Zipper<ScalarFieldId>>> for FieldSelection

source§

fn from(fields: Vec<ScalarFieldRef>) -> Self

Converts to this type from the input type.
source§

impl Hash for FieldSelection

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 IntoIterator for FieldSelection

§

type Item = SelectedField

The type of the elements being iterated over.
§

type IntoIter = IntoIter<<FieldSelection as IntoIterator>::Item>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq for FieldSelection

source§

fn eq(&self, other: &FieldSelection) -> 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 ScalarCompare for FieldSelection

source§

fn is_in<T>(&self, values: T) -> Filterwhere T: Into<ConditionListValue>,

Field is in a given value

source§

fn not_in<T>(&self, values: T) -> Filterwhere T: Into<ConditionListValue>,

Field is not in a given value

source§

fn equals<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field equals the given value.

source§

fn not_equals<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field does not equal the given value.

source§

fn contains<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field contains the given value.

source§

fn not_contains<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field does not contain the given value.

source§

fn starts_with<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field starts with the given value.

source§

fn not_starts_with<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field does not start with the given value.

source§

fn ends_with<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field ends with the given value.

source§

fn not_ends_with<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field does not end with the given value.

source§

fn less_than<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field is less than the given value.

source§

fn less_than_or_equals<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field is less than or equals the given value.

source§

fn greater_than<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field is greater than the given value.

source§

fn greater_than_or_equals<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

Field is greater than or equals the given value.

source§

fn search<T>(&self, val: T) -> Filterwhere T: Into<ConditionValue>,

source§

fn is_set(&self, val: bool) -> Filter

source§

impl Eq for FieldSelection

source§

impl StructuralEq for FieldSelection

source§

impl StructuralPartialEq for FieldSelection

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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