Skip to main content

Relationship

Enum Relationship 

Source
pub enum Relationship {
    ForeignKey {
        table: QualifiedIdentifier,
        foreign_table: QualifiedIdentifier,
        is_self: bool,
        cardinality: Cardinality,
        table_is_view: bool,
        foreign_table_is_view: bool,
        constraint_name: String,
    },
    Computed {
        function: QualifiedIdentifier,
        table: QualifiedIdentifier,
        foreign_table: QualifiedIdentifier,
        table_alias: QualifiedIdentifier,
        to_one: bool,
        is_self: bool,
        row_argument: Option<String>,
    },
}
Expand description

A relationship between tables.

Variants§

§

ForeignKey

Foreign key relationship

Fields

§table: QualifiedIdentifier

Source table

§foreign_table: QualifiedIdentifier

Target table

§is_self: bool

Whether this is a self-referential relationship

§cardinality: Cardinality

Relationship cardinality

§table_is_view: bool

Whether the source is a view

§foreign_table_is_view: bool

Whether the target is a view

§constraint_name: String

FK constraint name

§

Computed

Computed relationship (from a function)

Fields

§function: QualifiedIdentifier

Function that computes the relationship

§table: QualifiedIdentifier

Source table

§foreign_table: QualifiedIdentifier

Target table

§table_alias: QualifiedIdentifier

Alias for the relationship

§to_one: bool

Whether this returns a single row

§is_self: bool

Whether this is self-referential

§row_argument: Option<String>

The name of the parameter that takes the parent’s row.

Usually the only one, and then the call is positional. A function that also takes a search term or the caller’s session has the row somewhere among its parameters and is called by name, which is why the name is kept rather than the position.

Implementations§

Source§

impl Relationship

Source

pub fn foreign_table(&self) -> &QualifiedIdentifier

Get the foreign table for this relationship.

Source

pub fn is_to_one(&self) -> bool

Check if this relationship returns a single row.

Source

pub fn constraint_name(&self) -> &str

The name of the foreign key constraint behind this relationship.

Empty for a many-to-many, which is two constraints rather than one, and for a computed relationship, which has none.

Source

pub fn cardinality_name(&self) -> &'static str

How PostgREST names this relationship’s cardinality.

Source

pub fn describe(&self) -> String

How this relationship reads when several of them cannot be told apart.

message_sender_fkey using message(sender) and person_detail(id) – the constraint, then each side with the columns it joins on, which is what a client needs to write the hint that disambiguates it.

Source

pub fn disambiguator(&self) -> String

The !hint that picks this relationship out from its rivals.

The constraint for a foreign key, the junction table for a many-to-many: whichever name is the one a client would have to write to mean this relationship and no other.

Source

pub fn matches_hint(&self, hint: &str) -> bool

Whether a hint names this relationship.

A hint may be the constraint, the column that joins them, or the table on the far side – whichever the client found unambiguous.

Source

pub fn is_self_referential(&self) -> bool

Whether this is a self-referential foreign key.

Source

pub fn is_one_to_many(&self) -> bool

Whether this relationship yields many rows per row of its own table.

Source

pub fn single_local_column(&self) -> Option<&str>

The single column this side joins on, where it joins on exactly one.

Source

pub fn single_foreign_column(&self) -> Option<&str>

The single column the other side joins on, where there is exactly one.

Source

pub fn join_columns(&self) -> Vec<(String, String)>

Get the join columns for this relationship.

Trait Implementations§

Source§

impl Clone for Relationship

Source§

fn clone(&self) -> Relationship

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Relationship

Source§

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

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

impl<'de> Deserialize<'de> for Relationship

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Relationship

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

type Error = !

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

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more