1use super::*;
3
4mod log; pub use log::Log;
5
6#[cfg(feature="sqlite")]
7pub mod sqlite;
8
9#[cfg(feature="mysql")]
10pub mod mysql;
11
12#[cfg(feature="postgres")]
13pub mod postgres;
14
15#[cfg(test)]
16pub mod proxy_test {
17 use super::*;
18
19 pub fn run_connection<S, R>(s: &mut S) -> Result<()>
20 where S: traits::Connection<R>,
21 R: traits::Row,
22 {
23 s.query_drop("DROP TABLE IF EXISTS mytable_proxy_conn")?;
24
25 s.query_drop("CREATE TABLE mytable_proxy_conn (
26 id INTEGER,
27 name TEXT
28 )")?;
29
30 s.execute_with_params("INSERT INTO mytable_proxy_conn (id, name) VALUES (?, ?)",
31 &(1i64, "my name".to_string())
32 )?;
33
34 let r: String = s.query_first("SELECT name FROM mytable_proxy_conn")?
35 .map(|r| Ok::<_, Error>(r.get::<String>(0).ok_or(Error::ResultConversionFail("String".to_string()))??.clone()))
36 .ok_or(Error::QueryReturnNoResult)??;
37 assert!(r.eq("my name"));
38
39 Ok(())
40 }
41
42 pub fn run_with_date<S, R>(s: &mut S) -> Result<()>
43 where S: traits::Connection<R>,
44 R: traits::Row,
45 {
46 use chrono::Datelike;
47
48 s.query_drop("DROP TABLE IF EXISTS run_with_date")?;
49
50 s.query_drop("CREATE TABLE run_with_date (
51 date DATE
52 )")?;
53
54 s.execute_with_params("INSERT INTO run_with_date (date) VALUES (?)",
55 &chrono::naive::NaiveDate::from_ymd_opt(2024, 1, 2).ok_or("Invalid date")?,
56 )?;
57
58 let r: chrono::naive::NaiveDate = s.query_first("SELECT * FROM run_with_date")?
59 .map(|r| Ok::<_, Error>(r.get::<chrono::naive::NaiveDate>(0).ok_or(Error::ResultConversionFail("NaiveDate".to_string()))??))
60 .ok_or(Error::QueryReturnNoResult)??;
61 assert!(r.year() == 2024);
62 assert!(r.month() == 1);
63 assert!(r.day() == 2);
64
65 Ok(())
66 }
67}