From f8fec23264acd576860509d6cf68d49b23330fc3 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 10 Mar 2022 00:02:40 +0100 Subject: 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. --- src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main.rs') 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, + table_columns: &HashMap, ) { 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 { +fn get_column_names(dbconn: &rusqlite::Connection) -> HashMap { let mut column_names = HashMap::new(); let mut stmt = dbconn.prepare(r#" @@ -103,8 +103,11 @@ fn get_column_names(dbconn: &rusqlite::Connection) -> HashMap { 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 -- cgit v1.2.3