pub struct SchemaBuilder { /* private fields */ }Expand description
Builder for creating schemas more ergonomically
Implementations§
Source§impl SchemaBuilder
impl SchemaBuilder
Sourcepub fn from_schema(schema: &Schema) -> Self
pub fn from_schema(schema: &Schema) -> Self
Continue binding constraints against an existing schema.
Sourcepub fn column(
self,
name: impl Into<String>,
data_type: DataType,
nullable: bool,
primary_key: bool,
) -> Self
pub fn column( self, name: impl Into<String>, data_type: DataType, nullable: bool, primary_key: bool, ) -> Self
Add a column
Sourcepub fn add(self, name: impl Into<String>, data_type: DataType) -> Self
pub fn add(self, name: impl Into<String>, data_type: DataType) -> Self
Add a simple non-nullable column
Sourcepub fn add_nullable(self, name: impl Into<String>, data_type: DataType) -> Self
pub fn add_nullable(self, name: impl Into<String>, data_type: DataType) -> Self
Add a nullable column
Sourcepub fn add_primary_key(
self,
name: impl Into<String>,
data_type: DataType,
) -> Self
pub fn add_primary_key( self, name: impl Into<String>, data_type: DataType, ) -> Self
Add a primary key column
Sourcepub fn add_with_constraints(
self,
name: impl Into<String>,
data_type: DataType,
nullable: bool,
primary_key: bool,
auto_increment: bool,
default_expr: Option<String>,
check_expr: Option<String>,
) -> Self
pub fn add_with_constraints( self, name: impl Into<String>, data_type: DataType, nullable: bool, primary_key: bool, auto_increment: bool, default_expr: Option<String>, check_expr: Option<String>, ) -> Self
Add a column with full constraints (default, check)
Sourcepub fn set_last_vector_dimensions(self, dims: u16) -> Self
pub fn set_last_vector_dimensions(self, dims: u16) -> Self
Set vector dimensions on the last added column
Sourcepub fn set_last_decimal_parameters(self, precision: u8, scale: u8) -> Self
pub fn set_last_decimal_parameters(self, precision: u8, scale: u8) -> Self
Set DECIMAL precision/scale on the last added column.
Sourcepub fn set_last_text_max_chars(self, max_chars: u32) -> Self
pub fn set_last_text_max_chars(self, max_chars: u32) -> Self
Set the logical TEXT(n) character limit on the last added column.
Sourcepub fn set_last_double_precision(self, double_precision: bool) -> Self
pub fn set_last_double_precision(self, double_precision: bool) -> Self
Mark the last f64-backed column as SQL DOUBLE PRECISION.
pub fn set_last_external_type( self, type_ref: ExternalTypeRef, sql_name: impl Into<String>, ) -> Self
Sourcepub fn set_last_default_value(self, default_value: Option<Value>) -> Self
pub fn set_last_default_value(self, default_value: Option<Value>) -> Self
Set pre-computed default value on the last added column.
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Find column index by name (case-insensitive)
Sourcepub fn is_column_nullable(&self, idx: usize) -> bool
pub fn is_column_nullable(&self, idx: usize) -> bool
Check if a column is nullable by index
Sourcepub fn column_data_type(&self, idx: usize) -> Option<DataType>
pub fn column_data_type(&self, idx: usize) -> Option<DataType>
Return the declared type of a column already admitted by the builder.
pub fn column_logical_type(&self, idx: usize) -> Option<LogicalTypeRef>
Sourcepub fn column_definition(&self, idx: usize) -> Option<&SchemaColumn>
pub fn column_definition(&self, idx: usize) -> Option<&SchemaColumn>
Inspect a column already admitted by the builder.
Sourcepub fn primary_key_column(&self) -> Option<(usize, &SchemaColumn)>
pub fn primary_key_column(&self) -> Option<(usize, &SchemaColumn)>
Return the single declared primary-key column, if present.
Sourcepub fn add_foreign_key(self, fk: ForeignKeyConstraint) -> Self
pub fn add_foreign_key(self, fk: ForeignKeyConstraint) -> Self
Add a foreign key constraint
Sourcepub fn add_table_check(self, expression: impl Into<String>) -> Self
pub fn add_table_check(self, expression: impl Into<String>) -> Self
Add a CHECK constraint evaluated against the complete row.