pub struct SchemaObject {
pub kind: String,
pub name: String,
pub table: String,
pub root: u32,
pub sql: String,
}Expand description
One row of sqlite_schema.
Fields§
§kind: Stringtable, index, view or trigger.
name: StringThe object’s name.
table: StringThe table the object belongs to; for a table, its own name.
root: u32The root page, or 0 for an object with no b-tree.
sql: StringThe CREATE statement the object was declared with.
Implementations§
Source§impl SchemaObject
impl SchemaObject
Sourcepub fn column_names(&self) -> DbResult<Vec<String>>
pub fn column_names(&self) -> DbResult<Vec<String>>
Returns the column names the CREATE TABLE statement declares.
A deliberately small parser: it takes the text between the outermost
parentheses, splits on commas that are not inside parentheses, and reads
the first identifier of each part. That is enough for the fixtures and
for the tables inillucent-migrate has to read, and it refuses rather than
guesses on anything it does not recognise - a table constraint
(PRIMARY KEY (...), UNIQUE (...), FOREIGN KEY, CHECK) is skipped
rather than mistaken for a column.
A general answer needs the real parser in inillucent-sql, and this crate
deliberately sits below it so that a migration tool does not drag the
front end in. Phase 4 revisits this when DDL import needs types and
constraints as well as names.