Skip to main content

Column

Struct Column 

Source
pub struct Column {
    pub schema: Cow<'static, str>,
    pub table: Cow<'static, str>,
    pub name: Cow<'static, str>,
    pub sql_type: Cow<'static, str>,
    pub type_schema: Option<Cow<'static, str>>,
    pub not_null: bool,
    pub default: Option<Cow<'static, str>>,
    pub generated: Option<Generated>,
    pub identity: Option<Identity>,
    pub dimensions: Option<i32>,
    pub collate: Option<Cow<'static, str>>,
    pub ordinal_position: Option<i32>,
}
Expand description

Runtime column entity for serde serialization.

Fields§

§schema: Cow<'static, str>

Schema name

§table: Cow<'static, str>

Parent table name

§name: Cow<'static, str>

Column name

§sql_type: Cow<'static, str>

SQL type (e.g., “INTEGER”, “TEXT”, “VARCHAR”)

§type_schema: Option<Cow<'static, str>>

Type schema (for custom types)

§not_null: bool

Is this column NOT NULL?

§default: Option<Cow<'static, str>>

Default value as string

§generated: Option<Generated>

Generated column configuration

§identity: Option<Identity>

Identity column configuration

§dimensions: Option<i32>

Array dimensions (for array types)

§collate: Option<Cow<'static, str>>

Collation name (e.g. "en_US", "C"). None means the database default collation and no COLLATE clause is emitted.

§ordinal_position: Option<i32>

Ordinal position within the table (1-based).

This is primarily populated by introspection and used for stable codegen ordering.

Implementations§

Source§

impl Column

Source

pub fn new( schema: impl Into<Cow<'static, str>>, table: impl Into<Cow<'static, str>>, name: impl Into<Cow<'static, str>>, sql_type: impl Into<Cow<'static, str>>, ) -> Self

Create a new column (runtime)

Source

pub const fn not_null(self) -> Self

Set NOT NULL

Source

pub fn default_value(self, value: impl Into<Cow<'static, str>>) -> Self

Set default value

Source

pub fn identity(self, identity: Identity) -> Self

Set identity configuration

Source

pub fn schema(&self) -> &str

Get the schema name

Source

pub fn table(&self) -> &str

Get the table name

Source

pub fn name(&self) -> &str

Get the column name

Source

pub fn sql_type(&self) -> &str

Get the SQL type

Source§

impl Column

Source

pub fn to_column_sql(&self) -> String

Generate the column definition SQL (without leading/trailing punctuation)

Source

pub fn add_column_sql(&self) -> String

Generate ADD COLUMN SQL

Source

pub fn drop_column_sql(&self) -> String

Generate DROP COLUMN SQL

Trait Implementations§

Source§

impl Clone for Column

Source§

fn clone(&self) -> Column

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Column

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Column

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<ColumnDef> for Column

Source§

fn from(def: ColumnDef) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Column

Source§

fn eq(&self, other: &Column) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Column

Source§

impl StructuralPartialEq for Column

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 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.