pub struct ForeignKeyRef {
pub table: ObjectName,
pub columns: ThinVec<Ident>,
pub match_type: Option<ForeignKeyMatch>,
pub on_delete: Option<Box<ReferentialAction>>,
pub on_update: Option<Box<ReferentialAction>>,
pub update_before_delete: bool,
pub meta: Meta,
}Expand description
A foreign-key reference: REFERENCES <table> [(<column>, ...)] plus the
optional <referential triggered action> clauses.
match_type, on_delete, and on_update stay None when their clause is
unwritten — the canonical shape keeps one node for both the column-level
REFERENCES form and the table-level FOREIGN KEY form. The clauses
are order-independent in the standard, so the parser accepts them in any order
and renders them in a fixed canonical order (ON DELETE before ON UPDATE); the
update_before_delete tag records the one bit of
order the two separate fields otherwise lose, so a source-fidelity render replays
the written order. PostgreSQL always materializes these (defaulting MATCH SIMPLE
/ NO ACTION), so an unwritten clause and the explicit default are
representation-equivalent.
Fields§
§table: ObjectNameTable referenced by this syntax.
columns: ThinVec<Ident>Columns in source order.
match_type: Option<ForeignKeyMatch>Optional match type for this syntax.
on_delete: Option<Box<ReferentialAction>>The referential actions are boxed because they are usually absent and a
ReferentialAction is comparatively large: a bare REFERENCES then pays
only a null pointer, keeping the inline node small where this type is
embedded in ColumnOption/TableConstraint (the same reason those
enums box their generated-column and identity payloads).
on_update: Option<Box<ReferentialAction>>Optional on update for this syntax.
update_before_delete: boolWhether the source wrote ON UPDATE before ON DELETE. Meaningful only when
both actions are present; the canonical render emits ON DELETE first, and a
source-fidelity render swaps to the written order. Exact-order fidelity — the
clauses are order-independent, so a target re-spell and the redacted fingerprint
keep the canonical order.
meta: MetaSource location and node identity.
Trait Implementations§
Source§impl Clone for ForeignKeyRef
impl Clone for ForeignKeyRef
Source§fn clone(&self) -> ForeignKeyRef
fn clone(&self) -> ForeignKeyRef
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 ForeignKeyRef
impl Debug for ForeignKeyRef
Source§impl<'de> Deserialize<'de> for ForeignKeyRef
impl<'de> Deserialize<'de> for ForeignKeyRef
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>,
impl Eq for ForeignKeyRef
Source§impl Hash for ForeignKeyRef
impl Hash for ForeignKeyRef
Source§impl PartialEq for ForeignKeyRef
impl PartialEq for ForeignKeyRef
Source§impl Render for ForeignKeyRef
impl Render for ForeignKeyRef
Source§fn render(&self, ctx: &RenderCtx<'_>, f: &mut Formatter<'_>) -> Result
fn render(&self, ctx: &RenderCtx<'_>, f: &mut Formatter<'_>) -> Result
Source§fn operand_binding_power(&self) -> Option<BindingPower>
fn operand_binding_power(&self) -> Option<BindingPower>
None (the default) for a self-delimiting node — an atom, call, or
constructor — that never needs parentheses. Read moreSource§impl Serialize for ForeignKeyRef
impl Serialize for ForeignKeyRef
impl StructuralPartialEq for ForeignKeyRef
Auto Trait Implementations§
impl Freeze for ForeignKeyRef
impl RefUnwindSafe for ForeignKeyRef
impl Send for ForeignKeyRef
impl Sync for ForeignKeyRef
impl Unpin for ForeignKeyRef
impl UnsafeUnpin for ForeignKeyRef
impl UnwindSafe for ForeignKeyRef
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> DynAstExt for T
impl<T> DynAstExt for T
Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&dyn Any for downcasting a node back to its concrete type.Source§fn dyn_clone(&self) -> Box<dyn DynAstExt>
fn dyn_clone(&self) -> Box<dyn DynAstExt>
Clone (whose
Self-returning signature cannot go through a vtable).Source§fn dyn_eq(&self, other: &dyn DynAstExt) -> bool
fn dyn_eq(&self, other: &dyn DynAstExt) -> bool
PartialEq (whose &Self argument cannot go through a vtable). Equal
iff other holds the same concrete type and that type deems the values
equal; differently-typed nodes are never equal.