diff options
author | Teddy Wing | 2022-03-12 21:26:54 +0100 |
---|---|---|
committer | Teddy Wing | 2022-03-12 21:26:54 +0100 |
commit | 48457ecc2e6e85cfd38644c2d18858a24a7f78d0 (patch) | |
tree | 54257e66e2503557fe91a075ac29f65dc19fa55c /src | |
parent | db05a516596857f0e754d6cd48fe7c9669843731 (diff) | |
download | yaqlite-48457ecc2e6e85cfd38644c2d18858a24a7f78d0.tar.bz2 |
get_column_names(): Restore `Zero` value
Turns out I didn't need the type of the column, so get rid of that value
and resume using `Zero`.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index 48d01b4..ae65cb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,7 +31,7 @@ fn main() { fn yaml_extract( doc: &mut yaml::Yaml, tx: &rusqlite::Transaction, - table_columns: &HashMap<String, rusqlite::types::Type>, + table_columns: &HashMap<String, Zero>, ) { match doc { yaml::Yaml::Array(ref mut array) => { @@ -107,19 +107,18 @@ struct Zero {} use std::collections::HashMap; -fn get_column_names(dbconn: &rusqlite::Connection) -> HashMap<String, rusqlite::types::Type> { +// TODO: We don't need to include the type in the HashMap. Go back to Zero. +fn get_column_names(dbconn: &rusqlite::Connection) -> HashMap<String, Zero> { let mut column_names = HashMap::new(); let mut stmt = dbconn.prepare(r#" - SELECT - "name", - "type" + SELECT "name" FROM pragma_table_info("people"); "#).unwrap(); let rows = stmt.query_map( [], - |row| Ok((row.get(0).unwrap(), row.get(1).unwrap())), + |row| row.get(0), ).unwrap(); for row_result in rows { @@ -139,11 +138,7 @@ fn get_column_names(dbconn: &rusqlite::Connection) -> HashMap<String, rusqlite:: let row = row_result.unwrap(); - let type_name: String = row.1; - - let type_affinity = yaqlite::sqlite::affinity(&type_name); - - column_names.insert(row.0, type_affinity); + column_names.insert(row, Zero{}); } column_names |