pub struct TableDefinition {
pub name: String,
pub primary_key: ColumnDefinition,
pub columns: Vec<ColumnDefinition>,
pub foreign_keys: Vec<ForeignKeyDefinition>,
pub composite_primary_key: Option<Vec<String>>,
}Expand description
Table schema definition (no generators).
Used for schema introspection during incremental sync operations. Contains the table name, primary key column, and all columns.
Fields§
§name: StringTable name
primary_key: ColumnDefinitionPrimary key column definition (first PK column for composite keys)
columns: Vec<ColumnDefinition>Column definitions (excluding primary key)
foreign_keys: Vec<ForeignKeyDefinition>Foreign key constraints on this table
composite_primary_key: Option<Vec<String>>Composite primary key column names (when PK spans multiple columns).
None means the PK is the single primary_key field.
Implementations§
Source§impl TableDefinition
impl TableDefinition
Sourcepub fn new(
name: impl Into<String>,
primary_key: ColumnDefinition,
columns: Vec<ColumnDefinition>,
) -> Self
pub fn new( name: impl Into<String>, primary_key: ColumnDefinition, columns: Vec<ColumnDefinition>, ) -> Self
Create a new table definition.
Sourcepub fn get_column(&self, name: &str) -> Option<&ColumnDefinition>
pub fn get_column(&self, name: &str) -> Option<&ColumnDefinition>
Get a column by name (searches both primary key and columns).
Sourcepub fn get_column_type(&self, name: &str) -> Option<&Type>
pub fn get_column_type(&self, name: &str) -> Option<&Type>
Get the type of a column by name.
Sourcepub fn column_names(&self) -> Vec<&str>
pub fn column_names(&self) -> Vec<&str>
Get all column names (including primary key).
Sourcepub fn primary_key_column_names(&self) -> Vec<&str>
pub fn primary_key_column_names(&self) -> Vec<&str>
Get the primary key column names (supports composite keys).
Trait Implementations§
Source§impl Clone for TableDefinition
impl Clone for TableDefinition
Source§fn clone(&self) -> TableDefinition
fn clone(&self) -> TableDefinition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TableDefinition
impl Debug for TableDefinition
Source§impl<'de> Deserialize<'de> for TableDefinition
impl<'de> Deserialize<'de> for TableDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TableDefinition
impl RefUnwindSafe for TableDefinition
impl Send for TableDefinition
impl Sync for TableDefinition
impl Unpin for TableDefinition
impl UnsafeUnpin for TableDefinition
impl UnwindSafe for TableDefinition
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