diff --git a/njord/src/sqlite/query.rs b/njord/src/sqlite/query.rs index fae57c15..9be59887 100644 --- a/njord/src/sqlite/query.rs +++ b/njord/src/sqlite/query.rs @@ -44,7 +44,7 @@ impl<'a> QueryBuilder<'a> { } // Result>>> - pub fn build(mut self) -> Result>> { + pub fn build(mut self) -> Result>> { let columns_str = self.columns.join(", "); let table_name = self .table @@ -94,13 +94,13 @@ impl<'a> QueryBuilder<'a> { let iter = stmt.query_map((), |row| { let mut result_row = HashMap::new(); for (i, column) in self.columns.iter().enumerate() { - let value: String = format!("{:?}", row.get_unwrap::(i)); + let value = row.get_unwrap::(i); result_row.insert(column.clone(), value); } Ok(result_row) })?; - let result: Result>> = iter.collect(); + let result: Result>> = iter.collect(); result.map_err(|err| err.into()) } } diff --git a/njord/tests/sqlite_test.rs b/njord/tests/sqlite_test.rs index d06d46b3..3ae21f7a 100644 --- a/njord/tests/sqlite_test.rs +++ b/njord/tests/sqlite_test.rs @@ -1,5 +1,6 @@ // integrations tests for sqlite +use rusqlite::types::Value; use njord::sqlite::{self, Condition}; use njord::table::Table; @@ -114,7 +115,20 @@ fn select() { // currently returns error with "ExecuteReturnedResults" match result { - Ok(result) => println!("{:?}", result), + Ok(result) => { + for row in result { + for (column, value) in &row { + match value { + Value::Null => println!("{}: NULL", column), + Value::Integer(i) => println!("{}: {}", column, i), + Value::Real(f) => println!("{}: {}", column, f), + Value::Text(s) => println!("{}: {}", column, s), + Value::Blob(b) => println!("{}: ", column, b.len()), + } + } + println!("---"); // Separate rows for clarity + } + }, Err(error) => panic!("Failed to SELECT: {:?}", error), }; }