#![allow(clippy::suspicious_map)] use std::time::SystemTime; use amadeus::prelude::*; #[tokio::test(threaded_scheduler)] #[cfg_attr(miri, ignore)] async fn postgres() { let start = SystemTime::now(); let pool = &ThreadPool::new(None, None).unwrap(); #[derive(Data, Clone, PartialEq, PartialOrd, Debug)] struct Weather { city: Option, temp_lo: Option, temp_hi: Option, prcp: Option, date: Option, invent: Option, } #[derive(Data, Clone, PartialEq, PartialOrd, Debug)] struct InventoryItem { name: Option, supplier_id: Option, price: Option, } // https://datahub.io/cryptocurrency/bitcoin let rows = Postgres::::new(vec![( "postgres://postgres:a@localhost/alec".parse().unwrap(), vec![PostgresSelect::Table("weather".parse().unwrap())], )]); assert_eq!( rows.par_stream() .map(|row: Result<_, _>| row.unwrap()) .count(&pool) .await, 4 ); // TODO // let rows = Postgres::::new(vec![( // "postgres://postgres:a@localhost/alec".parse().unwrap(), // vec![amadeus::source::postgres::Source::Table( // "weather".parse().unwrap(), // )], // )]); // assert_eq!( // rows.par_stream() // .map(|row: Result| -> Value { // let value = row.unwrap(); // // println!("{:?}", value); // // let _: GameDerived = value.clone().downcast().unwrap(); // value // }) // .count(&pool).await, // 4 // ); println!("in {:?}", start.elapsed().unwrap()); }