Skip to main content

SchemaBuilder

Struct SchemaBuilder 

Source
pub struct SchemaBuilder { /* private fields */ }
Expand description

Builder for creating schemas more ergonomically

Implementations§

Source§

impl SchemaBuilder

Source

pub fn new(table_name: impl Into<String>) -> Self

Create a new schema builder

Source

pub fn from_schema(schema: &Schema) -> Self

Continue binding constraints against an existing schema.

Source

pub fn column( self, name: impl Into<String>, data_type: DataType, nullable: bool, primary_key: bool, ) -> Self

Add a column

Source

pub fn add(self, name: impl Into<String>, data_type: DataType) -> Self

Add a simple non-nullable column

Source

pub fn add_nullable(self, name: impl Into<String>, data_type: DataType) -> Self

Add a nullable column

Source

pub fn add_primary_key( self, name: impl Into<String>, data_type: DataType, ) -> Self

Add a primary key column

Source

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)

Source

pub fn set_last_vector_dimensions(self, dims: u16) -> Self

Set vector dimensions on the last added column

Source

pub fn set_last_decimal_parameters(self, precision: u8, scale: u8) -> Self

Set DECIMAL precision/scale on the last added column.

Source

pub fn set_last_external_type( self, type_ref: ExternalTypeRef, sql_name: impl Into<String>, ) -> Self

Source

pub fn set_last_default_value(self, default_value: Option<Value>) -> Self

Set pre-computed default value on the last added column.

Source

pub fn column_index(&self, name: &str) -> Option<usize>

Find column index by name (case-insensitive)

Source

pub fn is_column_nullable(&self, idx: usize) -> bool

Check if a column is nullable by index

Source

pub fn column_data_type(&self, idx: usize) -> Option<DataType>

Return the declared type of a column already admitted by the builder.

Source

pub fn column_logical_type(&self, idx: usize) -> Option<LogicalTypeRef>

Source

pub fn column_definition(&self, idx: usize) -> Option<&SchemaColumn>

Inspect a column already admitted by the builder.

Source

pub fn primary_key_column(&self) -> Option<(usize, &SchemaColumn)>

Return the single declared primary-key column, if present.

Source

pub fn add_foreign_key(self, fk: ForeignKeyConstraint) -> Self

Add a foreign key constraint

Source

pub fn add_table_check(self, expression: impl Into<String>) -> Self

Add a CHECK constraint evaluated against the complete row.

Source

pub fn build(self) -> Schema

Build the schema

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> CompactArcDrop for T

Source§

unsafe fn drop_and_dealloc(ptr: *mut u8)

Drop the contained data and deallocate the header+data allocation. 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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V