From 48457ecc2e6e85cfd38644c2d18858a24a7f78d0 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 12 Mar 2022 21:26:54 +0100 Subject: 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`. --- src/main.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src') 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, + table_columns: &HashMap, ) { 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 { +// TODO: We don't need to include the type in the HashMap. Go back to Zero. +fn get_column_names(dbconn: &rusqlite::Connection) -> HashMap { 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