Struct TableDef
pub struct TableDef {
pub name: String,
pub foreign_keys: Vec<ForeignKeysInfo>,
pub indexes: Vec<IndexInfo>,
pub constraints: Vec<IndexInfo>,
pub columns: Vec<ColumnInfo>,
pub auto_increment: bool,
}Expand description
Defines a table for SQLite
Fields§
§name: StringThe table name
foreign_keys: Vec<ForeignKeysInfo>A list of foreign keys in the table
indexes: Vec<IndexInfo>A list of the indexes in the table
constraints: Vec<IndexInfo>A list of UNIQUE and PRIMARY KEY constraints on the table
columns: Vec<ColumnInfo>A list of all the columns and their types
auto_increment: boolWhether the primary key should autoincrement
Implementations§
§impl TableDef
impl TableDef
pub async fn pk_is_autoincrement(
&mut self,
conn: &impl Connection,
) -> DiscoveryResult<&mut Self>
pub async fn pk_is_autoincrement( &mut self, conn: &impl Connection, ) -> DiscoveryResult<&mut Self>
Check if the primary key in the table is set to autoincrement as a result of using query `SELECT COUNT(*) from sqlite_sequence where name = ‘table_name’;
pub async fn get_constraints(
&mut self,
conn: &impl Connection,
) -> DiscoveryResult<()>
pub async fn get_constraints( &mut self, conn: &impl Connection, ) -> DiscoveryResult<()>
Get a list of most of the UNIQUE and PRIMARY KEY constraints on the table.
These are implemented by indexes in most cases. These indexes have type “u” or “pk”.
Note that this does not get the column name mapped by the index.
To get the column name mapped by the index, the self.get_single_indexinfo method is invoked
pub async fn get_indexes(
&mut self,
conn: &impl Connection,
) -> DiscoveryResult<()>
pub async fn get_indexes( &mut self, conn: &impl Connection, ) -> DiscoveryResult<()>
Get a list of all the indexes in the table.
Note that this does not get the column name mapped by the index.
To get the column name mapped by the index, the self.get_single_indexinfo method is invoked
pub async fn get_foreign_keys(
&mut self,
conn: &impl Connection,
) -> DiscoveryResult<&mut Self>
pub async fn get_foreign_keys( &mut self, conn: &impl Connection, ) -> DiscoveryResult<&mut Self>
Get a list of all the foreign keys in the table
pub async fn get_column_info(
&mut self,
conn: &impl Connection,
) -> DiscoveryResult<&TableDef>
pub async fn get_column_info( &mut self, conn: &impl Connection, ) -> DiscoveryResult<&TableDef>
Get a list of all the columns in the table mapped as ColumnInfo