silly way to convert row into Vec of Strings from postgres types see https://docs.rs/postgres/latest/postgres/types/trait.FromSql.html
(row: &tokio_postgres::Row)
| 14 | /// silly way to convert row into Vec of Strings from postgres types |
| 15 | /// see https://docs.rs/postgres/latest/postgres/types/trait.FromSql.html |
| 16 | async fn row_to_str_vec(row: &tokio_postgres::Row) -> Vec<String> { |
| 17 | (0..row.len()) |
| 18 | .into_iter() |
| 19 | .map(|ci| match *row.columns().get(ci).unwrap().type_() { |
| 20 | Type::DATE => row.get::<usize, chrono::NaiveDate>(ci).to_string(), |
| 21 | Type::INT4 => row.get::<usize, i32>(ci).to_string(), |
| 22 | Type::INT8 => row.get::<usize, i64>(ci).to_string(), |
| 23 | _ => "blah".to_string(), |
| 24 | }) |
| 25 | .collect() |
| 26 | } |
| 27 | |
| 28 | async fn row_to_str_hashmap(row: &tokio_postgres::Row) -> HashMap<String, String> { |
| 29 | let values = row_to_str_vec(row).await; |
no outgoing calls
no test coverage detected