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: QualifiedIdentifierSource table
foreign_table: QualifiedIdentifierTarget table
cardinality: CardinalityRelationship cardinality
Computed
Computed relationship (from a function)
Fields
function: QualifiedIdentifierFunction that computes the relationship
table: QualifiedIdentifierSource table
foreign_table: QualifiedIdentifierTarget table
table_alias: QualifiedIdentifierAlias for the relationship
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
impl Relationship
Sourcepub fn foreign_table(&self) -> &QualifiedIdentifier
pub fn foreign_table(&self) -> &QualifiedIdentifier
Get the foreign table for this relationship.
Sourcepub fn constraint_name(&self) -> &str
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.
Sourcepub fn cardinality_name(&self) -> &'static str
pub fn cardinality_name(&self) -> &'static str
How PostgREST names this relationship’s cardinality.
Sourcepub fn describe(&self) -> String
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.
Sourcepub fn disambiguator(&self) -> String
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.
Sourcepub fn matches_hint(&self, hint: &str) -> bool
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.
Sourcepub fn is_self_referential(&self) -> bool
pub fn is_self_referential(&self) -> bool
Whether this is a self-referential foreign key.
Sourcepub fn is_one_to_many(&self) -> bool
pub fn is_one_to_many(&self) -> bool
Whether this relationship yields many rows per row of its own table.
Sourcepub fn single_local_column(&self) -> Option<&str>
pub fn single_local_column(&self) -> Option<&str>
The single column this side joins on, where it joins on exactly one.
Sourcepub fn single_foreign_column(&self) -> Option<&str>
pub fn single_foreign_column(&self) -> Option<&str>
The single column the other side joins on, where there is exactly one.
Sourcepub fn join_columns(&self) -> Vec<(String, String)>
pub fn join_columns(&self) -> Vec<(String, String)>
Get the join columns for this relationship.
Trait Implementations§
Source§impl Clone for Relationship
impl Clone for Relationship
Source§fn clone(&self) -> Relationship
fn clone(&self) -> Relationship
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Relationship
impl Debug for Relationship
Source§impl<'de> Deserialize<'de> for Relationship
impl<'de> Deserialize<'de> for Relationship
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Relationship
impl RefUnwindSafe for Relationship
impl Send for Relationship
impl Sync for Relationship
impl Unpin for Relationship
impl UnsafeUnpin for Relationship
impl UnwindSafe for Relationship
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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