pub struct UniqueConstraintDef {
pub schema: &'static str,
pub table: &'static str,
pub name: &'static str,
pub name_explicit: bool,
pub columns: &'static [Cow<'static, str>],
pub nulls_not_distinct: bool,
}Expand description
Const-friendly unique constraint definition
§Examples
use drizzle_types::postgres::ddl::UniqueConstraintDef;
use std::borrow::Cow;
const COLS: &[Cow<'static, str>] = &[Cow::Borrowed("email"), Cow::Borrowed("tenant_id")];
const UNIQ: UniqueConstraintDef = UniqueConstraintDef::new("public", "users", "uq_email_tenant")
.columns(COLS);Fields§
§schema: &'static strSchema name
table: &'static strParent table name
name: &'static strConstraint name
name_explicit: boolWhether the constraint name was explicitly specified
columns: &'static [Cow<'static, str>]Columns in the unique constraint
nulls_not_distinct: boolNULLS NOT DISTINCT flag (PostgreSQL 15+)
Implementations§
Source§impl UniqueConstraintDef
impl UniqueConstraintDef
Sourcepub const fn new(
schema: &'static str,
table: &'static str,
name: &'static str,
) -> Self
pub const fn new( schema: &'static str, table: &'static str, name: &'static str, ) -> Self
Create a new unique constraint definition
Sourcepub const fn columns(self, cols: &'static [Cow<'static, str>]) -> Self
pub const fn columns(self, cols: &'static [Cow<'static, str>]) -> Self
Set the columns in the unique constraint
Sourcepub const fn explicit_name(self) -> Self
pub const fn explicit_name(self) -> Self
Mark the name as explicitly specified
Sourcepub const fn nulls_not_distinct(self) -> Self
pub const fn nulls_not_distinct(self) -> Self
Set NULLS NOT DISTINCT
Sourcepub const fn into_unique_constraint(self) -> UniqueConstraint
pub const fn into_unique_constraint(self) -> UniqueConstraint
Convert to runtime UniqueConstraint type
Trait Implementations§
Source§impl Clone for UniqueConstraintDef
impl Clone for UniqueConstraintDef
Source§fn clone(&self) -> UniqueConstraintDef
fn clone(&self) -> UniqueConstraintDef
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 UniqueConstraintDef
impl Debug for UniqueConstraintDef
Source§impl Default for UniqueConstraintDef
impl Default for UniqueConstraintDef
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 Hash for UniqueConstraintDef
impl Hash for UniqueConstraintDef
Source§impl PartialEq for UniqueConstraintDef
impl PartialEq for UniqueConstraintDef
impl Copy for UniqueConstraintDef
impl Eq for UniqueConstraintDef
impl StructuralPartialEq for UniqueConstraintDef
Auto Trait Implementations§
impl Freeze for UniqueConstraintDef
impl RefUnwindSafe for UniqueConstraintDef
impl Send for UniqueConstraintDef
impl Sync for UniqueConstraintDef
impl Unpin for UniqueConstraintDef
impl UnwindSafe for UniqueConstraintDef
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