diff options
author | Teddy Wing | 2022-03-10 00:02:40 +0100 |
---|---|---|
committer | Teddy Wing | 2022-03-10 00:03:08 +0100 |
commit | f8fec23264acd576860509d6cf68d49b23330fc3 (patch) | |
tree | bc6da56469464eb89baf0be1b8ebf4401db5aaaa /src/main.rs | |
parent | 06d872db01752763daf4a423806bb5e0cd4bd3f7 (diff) | |
download | yaqlite-f8fec23264acd576860509d6cf68d49b23330fc3.tar.bz2 |
Start encoding SQLite affinity rules
Need to figure out what to do for NUMERIC affinity since Rusqlite
doesn't expose a variant for that pseudo-type.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index d289b01..e064baa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,7 +31,7 @@ fn main() { fn yaml_extract( doc: &yaml::Yaml, tx: &rusqlite::Transaction, - table_columns: &HashMap<String, String>, + table_columns: &HashMap<String, rusqlite::types::Type>, ) { match doc { yaml::Yaml::Array(ref array) => { @@ -71,7 +71,7 @@ struct Zero {} use std::collections::HashMap; -fn get_column_names(dbconn: &rusqlite::Connection) -> HashMap<String, String> { +fn get_column_names(dbconn: &rusqlite::Connection) -> HashMap<String, rusqlite::types::Type> { let mut column_names = HashMap::new(); let mut stmt = dbconn.prepare(r#" @@ -103,8 +103,11 @@ fn get_column_names(dbconn: &rusqlite::Connection) -> HashMap<String, String> { let row = row_result.unwrap(); - // TODO: Translate to rusqlite::types::Type. - column_names.insert(row.0, row.1); + let type_name: String = row.1; + + let type_affinity = yaqlite::sqlite::affinity(&type_name); + + column_names.insert(row.0, type_affinity); } column_names |