Skip to main content

PropertyBuilder

Struct PropertyBuilder 

Source
pub struct PropertyBuilder<'a, T, V = ()> { /* private fields */ }

Implementations§

Source§

impl<'a, T, V> PropertyBuilder<'a, T, V>

Source

pub fn is_required(self) -> Self

Source

pub fn is_optional(self) -> Self

Marks the column nullable (opposite of Self::is_required).

Source

pub fn has_column_type(self, sql_type: &str) -> Self

Overrides the database column type verbatim for every dialect (HasColumnType), e.g. "JSON", "MEDIUMTEXT", "DECIMAL(12,2)".

Source

pub fn has_precision(self, precision: u32, scale: u32) -> Self

Sets decimal/numeric precision and scale (HasPrecision(p, s)).

For temporal types the precision is emitted as the fractional-seconds precision (DATETIME(p) / TIMESTAMP(p)).

Source

pub fn is_fixed_length(self) -> Self

Uses a fixed-length string type (CHAR(n)), n = max_length.

Source

pub fn has_collation(self, name: &str) -> Self

Sets a column-level collation (HasCollation), emitted as COLLATE <name> (include quotes yourself for quoted names).

Source

pub fn has_comment(self, text: &str) -> Self

Sets a column comment (HasComment).

Source

pub fn has_computed_column_sql(self, sql: &str) -> Self

Declares a generated/computed column (HasComputedColumnSql).

sql is a raw SQL expression (e.g. unit_price * quantity). Computed columns are excluded from INSERT/UPDATE. Use Self::is_stored to persist the value (required by PostgreSQL).

Source

pub fn is_stored(self) -> Self

Persists a computed column (STORED); no-op for non-computed columns.

Source

pub fn is_concurrency_token(self) -> Self

Marks the column as an optimistic concurrency token.

Source

pub fn has_max_length(self, n: usize) -> Self

Source

pub fn has_column_name(self, name: &'static str) -> Self

Source

pub fn is_unique(self) -> Self

Source

pub fn has_index(self) -> Self

Source

pub fn has_default(self, sql: &str) -> Self

Sets a raw SQL DEFAULT expression, e.g. .has_default("1") or .has_default("CURRENT_TIMESTAMP"). String literals must include their quotes ("'pending'").

Source

pub fn has_check(self, expression: &str) -> Self

Adds a column-level CHECK constraint. The constraint name is derived as CK_<table>_<column> at model-build time (so table renames apply).

Auto Trait Implementations§

§

impl<'a, T, V = ()> !UnwindSafe for PropertyBuilder<'a, T, V>

§

impl<'a, T, V> Forget for PropertyBuilder<'a, T, V>

§

impl<'a, T, V> Freeze for PropertyBuilder<'a, T, V>

§

impl<'a, T, V> Move for PropertyBuilder<'a, T, V>

§

impl<'a, T, V> RefUnwindSafe for PropertyBuilder<'a, T, V>

§

impl<'a, T, V> Send for PropertyBuilder<'a, T, V>

§

impl<'a, T, V> Sync for PropertyBuilder<'a, T, V>

§

impl<'a, T, V> Unpin for PropertyBuilder<'a, T, V>

§

impl<'a, T, V> UnsafeUnpin for PropertyBuilder<'a, T, V>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.