pub struct PrimaryKeyDef {
pub table: &'static str,
pub name: &'static str,
pub columns: &'static [Cow<'static, str>],
pub name_explicit: bool,
}Expand description
A table’s primary key, buildable in a const.
TableSql writes a single-column key without an
explicit name inline on the column, and any other key as a table
constraint.
§Examples
use drizzle_types::sqlite::ddl::PrimaryKeyDef;
use std::borrow::Cow;
const COLS: &[Cow<'static, str>] = &[Cow::Borrowed("user_id"), Cow::Borrowed("role_id")];
const PK: PrimaryKeyDef = PrimaryKeyDef::new("user_roles", "pk_user_roles")
.columns(COLS);Fields§
§table: &'static strParent table name
name: &'static strConstraint name
columns: &'static [Cow<'static, str>]Columns in the primary key
name_explicit: boolWhether the user gave the constraint name (rather than it being generated)
Implementations§
Source§impl PrimaryKeyDef
impl PrimaryKeyDef
Sourcepub const fn new(table: &'static str, name: &'static str) -> Self
pub const fn new(table: &'static str, name: &'static str) -> Self
Creates a primary key with no columns; set them with
columns.
Sourcepub const fn explicit_name(self) -> Self
pub const fn explicit_name(self) -> Self
Marks the name as given by the user.
Sourcepub const fn into_primary_key(self) -> PrimaryKey
pub const fn into_primary_key(self) -> PrimaryKey
Converts to the runtime PrimaryKey.
Trait Implementations§
Source§impl Clone for PrimaryKeyDef
impl Clone for PrimaryKeyDef
impl Copy for PrimaryKeyDef
Source§impl Debug for PrimaryKeyDef
impl Debug for PrimaryKeyDef
Source§impl Default for PrimaryKeyDef
impl Default for PrimaryKeyDef
impl Eq for PrimaryKeyDef
Source§impl From<PrimaryKeyDef> for PrimaryKey
impl From<PrimaryKeyDef> for PrimaryKey
Source§fn from(def: PrimaryKeyDef) -> Self
fn from(def: PrimaryKeyDef) -> Self
Converts to this type from the input type.
Source§impl Hash for PrimaryKeyDef
impl Hash for PrimaryKeyDef
Source§impl PartialEq for PrimaryKeyDef
impl PartialEq for PrimaryKeyDef
impl StructuralPartialEq for PrimaryKeyDef
Auto Trait Implementations§
impl Freeze for PrimaryKeyDef
impl RefUnwindSafe for PrimaryKeyDef
impl Send for PrimaryKeyDef
impl Sync for PrimaryKeyDef
impl Unpin for PrimaryKeyDef
impl UnsafeUnpin for PrimaryKeyDef
impl UnwindSafe for PrimaryKeyDef
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