pub struct UniqueConstraint {
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 nulls_not_distinct: bool,
}Expand description
Runtime unique 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>]>Columns in the unique constraint
nulls_not_distinct: boolNULLS NOT DISTINCT flag (PostgreSQL 15+)
Implementations§
Source§impl UniqueConstraint
impl UniqueConstraint
Sourcepub fn to_constraint_sql(&self) -> String
pub fn to_constraint_sql(&self) -> String
Generate the UNIQUE constraint clause
Sourcepub fn add_unique_sql(&self) -> String
pub fn add_unique_sql(&self) -> String
Generate ADD UNIQUE SQL
Sourcepub fn drop_unique_sql(&self) -> String
pub fn drop_unique_sql(&self) -> String
Generate DROP UNIQUE SQL
Source§impl UniqueConstraint
impl UniqueConstraint
Sourcepub fn new(
schema: impl Into<Cow<'static, str>>,
table: impl Into<Cow<'static, str>>,
name: impl Into<Cow<'static, str>>,
columns: impl Into<Cow<'static, [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>>, columns: impl Into<Cow<'static, [Cow<'static, str>]>>, ) -> Self
Create a new unique constraint
Sourcepub fn from_strings(
schema: String,
table: String,
name: String,
columns: Vec<String>,
) -> UniqueConstraint
pub fn from_strings( schema: String, table: String, name: String, columns: Vec<String>, ) -> UniqueConstraint
Create a new unique constraint from owned strings (convenience for runtime construction)
Sourcepub fn explicit_name(self) -> Self
pub fn explicit_name(self) -> Self
Mark the name as explicitly specified
Trait Implementations§
Source§impl Clone for UniqueConstraint
impl Clone for UniqueConstraint
Source§fn clone(&self) -> UniqueConstraint
fn clone(&self) -> UniqueConstraint
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 UniqueConstraint
impl Debug for UniqueConstraint
Source§impl Default for UniqueConstraint
impl Default for UniqueConstraint
Source§impl From<UniqueConstraintDef> for UniqueConstraint
impl From<UniqueConstraintDef> for UniqueConstraint
Source§fn from(def: UniqueConstraintDef) -> Self
fn from(def: UniqueConstraintDef) -> Self
Converts to this type from the input type.
Source§impl PartialEq for UniqueConstraint
impl PartialEq for UniqueConstraint
impl Eq for UniqueConstraint
impl StructuralPartialEq for UniqueConstraint
Auto Trait Implementations§
impl Freeze for UniqueConstraint
impl RefUnwindSafe for UniqueConstraint
impl Send for UniqueConstraint
impl Sync for UniqueConstraint
impl Unpin for UniqueConstraint
impl UnwindSafe for UniqueConstraint
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