pub struct ConstraintNames;

Implementations§

source§

impl ConstraintNames

source

pub fn primary_key_name(table_name: &str, connector: &dyn Connector) -> String

Aligned with PG, to maximize the amount of times where we do not need to render names because they already align with our convention.

We always take the database names of entities. So if a model is remapped to a different name in the datamodel, the default name generation will still take the name of the table in the db as input. Same goes for fields / columns.

Postgres Naming conventions

Without column names {tablename}_{suffix} pkey for a Primary Key constraint

Including column names: {tablename}{columnname(s)}{suffix} column names are joined with an _ if there are multiple key for a Unique constraint idx for any other kind of index fkey for a Foreign key

additional for SQLServer: dflt for Default Constraint

not used for now: check for a Check constraint excl for an Exclusion constraint seq for sequences

source

pub fn unique_index_name( table_name: &str, column_names: &[&str], connector: &dyn Connector ) -> String

source

pub fn non_unique_index_name( table_name: &str, column_names: &[&str], connector: &dyn Connector ) -> String

source

pub fn default_name( table_name: &str, column_name: &str, connector: &dyn Connector ) -> String

source

pub fn foreign_key_constraint_name( table_name: &str, column_names: &[&str], connector: &dyn Connector ) -> String

Params:

  • table_name: the name of the constrained/referencing table, not the referenced one.
  • column names: the constrained column names
source

pub fn is_db_name_too_long( span: Span, object_name: &str, name: Option<&str>, attribute: &str, connector: &dyn Connector, double_at: bool ) -> Option<DatamodelError>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.