pub struct ForeignKey {
pub schema: Cow<'static, str>,
pub table: Cow<'static, str>,
pub name: Cow<'static, str>,
pub name_explicit: bool,
pub columns: Cow<'static, [Cow<'static, str>]>,
pub schema_to: Cow<'static, str>,
pub table_to: Cow<'static, str>,
pub columns_to: Cow<'static, [Cow<'static, str>]>,
pub on_update: Option<Cow<'static, str>>,
pub on_delete: Option<Cow<'static, str>>,
}Expand description
Runtime foreign key constraint entity
Uses Cow<'static, str> for all string fields, which works with both:
- Borrowed data from const definitions (
Cow::Borrowed) - Owned data from deserialization/introspection (
Cow::Owned)
Fields§
§schema: Cow<'static, str>Schema name
table: Cow<'static, str>Parent table name
name: Cow<'static, str>Constraint name
name_explicit: boolWhether the constraint name was explicitly specified
columns: Cow<'static, [Cow<'static, str>]>Source columns
schema_to: Cow<'static, str>Referenced schema name
table_to: Cow<'static, str>Referenced table name
columns_to: Cow<'static, [Cow<'static, str>]>Referenced columns
on_update: Option<Cow<'static, str>>ON UPDATE action
on_delete: Option<Cow<'static, str>>ON DELETE action
Implementations§
Source§impl ForeignKey
impl ForeignKey
Sourcepub fn new(
schema: impl Into<Cow<'static, str>>,
table: impl Into<Cow<'static, str>>,
name: impl Into<Cow<'static, str>>,
) -> Self
pub fn new( schema: impl Into<Cow<'static, str>>, table: impl Into<Cow<'static, str>>, name: impl Into<Cow<'static, str>>, ) -> Self
Create a new foreign key
Source§impl ForeignKey
impl ForeignKey
Sourcepub fn to_constraint_sql(&self) -> String
pub fn to_constraint_sql(&self) -> String
Generate the CONSTRAINT … FOREIGN KEY clause SQL
Sourcepub fn add_fk_sql(&self) -> String
pub fn add_fk_sql(&self) -> String
Generate ADD FOREIGN KEY SQL
Sourcepub fn drop_fk_sql(&self) -> String
pub fn drop_fk_sql(&self) -> String
Generate DROP FOREIGN KEY SQL
Trait Implementations§
Source§impl Clone for ForeignKey
impl Clone for ForeignKey
Source§fn clone(&self) -> ForeignKey
fn clone(&self) -> ForeignKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ForeignKey
impl Debug for ForeignKey
Source§impl Default for ForeignKey
impl Default for ForeignKey
Source§impl From<ForeignKeyDef> for ForeignKey
impl From<ForeignKeyDef> for ForeignKey
Source§fn from(def: ForeignKeyDef) -> Self
fn from(def: ForeignKeyDef) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ForeignKey
impl PartialEq for ForeignKey
impl Eq for ForeignKey
impl StructuralPartialEq for ForeignKey
Auto Trait Implementations§
impl Freeze for ForeignKey
impl RefUnwindSafe for ForeignKey
impl Send for ForeignKey
impl Sync for ForeignKey
impl Unpin for ForeignKey
impl UnwindSafe for ForeignKey
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
Mutably borrows from an owned value. Read more