pub struct ColumnDef { /* private fields */ }Expand description
Column definition for CREATE TABLE
This struct represents a column definition, including its type, constraints, and default value.
§Examples
ⓘ
use reinhardt_query::types::ddl::{ColumnDef, ColumnType};
// id INTEGER PRIMARY KEY AUTO_INCREMENT
let id_col = ColumnDef::new("id")
.column_type(ColumnType::Integer)
.primary_key(true)
.auto_increment(true);
// name VARCHAR(100) NOT NULL
let name_col = ColumnDef::new("name")
.column_type(ColumnType::String(Some(100)))
.not_null(true);Implementations§
Source§impl ColumnDef
impl ColumnDef
Sourcepub fn column_type(self, column_type: ColumnType) -> Self
pub fn column_type(self, column_type: ColumnType) -> Self
Set the column type
Sourcepub fn primary_key(self, primary_key: bool) -> Self
pub fn primary_key(self, primary_key: bool) -> Self
Set PRIMARY KEY constraint
Sourcepub fn auto_increment(self, auto_increment: bool) -> Self
pub fn auto_increment(self, auto_increment: bool) -> Self
Set AUTO_INCREMENT attribute
Sourcepub fn default(self, value: SimpleExpr) -> Self
pub fn default(self, value: SimpleExpr) -> Self
Set DEFAULT value
Sourcepub fn check(self, expr: SimpleExpr) -> Self
pub fn check(self, expr: SimpleExpr) -> Self
Set CHECK constraint
Sourcepub fn big_integer(self) -> Self
pub fn big_integer(self) -> Self
Set column type to BIGINT
Sourcepub fn small_integer(self) -> Self
pub fn small_integer(self) -> Self
Set column type to SMALLINT
Sourcepub fn tiny_integer(self) -> Self
pub fn tiny_integer(self) -> Self
Set column type to TINYINT
Sourcepub fn string_len(self, len: u32) -> Self
pub fn string_len(self, len: u32) -> Self
Set column type to VARCHAR(len)
Sourcepub fn decimal(self, precision: u32, scale: u32) -> Self
pub fn decimal(self, precision: u32, scale: u32) -> Self
Set column type to DECIMAL(precision, scale)
Sourcepub fn timestamp_with_time_zone(self) -> Self
pub fn timestamp_with_time_zone(self) -> Self
Set column type to TIMESTAMPTZ
Sourcepub fn json_binary(self) -> Self
pub fn json_binary(self) -> Self
Set column type to JSONB
Sourcepub fn binary_len(self, len: u32) -> Self
pub fn binary_len(self, len: u32) -> Self
Set column type to BINARY(len)
Alias for binary for reinhardt-query compatibility.
Sourcepub fn var_binary(self, len: u32) -> Self
pub fn var_binary(self, len: u32) -> Self
Set column type to VARBINARY(len)
Sourcepub fn array(self, element_type: ColumnType) -> Self
pub fn array(self, element_type: ColumnType) -> Self
Set column type to ARRAY of given element type
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ColumnDef
impl !RefUnwindSafe for ColumnDef
impl !Send for ColumnDef
impl !Sync for ColumnDef
impl Unpin for ColumnDef
impl UnsafeUnpin for ColumnDef
impl !UnwindSafe for ColumnDef
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