I try to implement helper for unit tests:
pub fn assert_sql_conversion<'a, T, R>(conn: &PgConnection, t: T, r: &'a R)
where
T: Table,
R: Debug + PartialEq,
&'a R: Insertable<T>,
InsertStatement<T, <&'a R as Insertable<T>>::Values>: ExecuteDsl<PgConnection> + LoadQuery<PgConnection, R>,
{
let v = diesel::insert_into(t).values(r).get_result(conn).unwrap();
assert_eq!(r, &v);
}
Usage:
common::assert_sql_conversion(&conn, test_uri::table, &TestUri { id: Url::new("http://example.com") });
Error:
error[E0275]: overflow evaluating the requirement `&(_, _, _, _, _): diesel::Insertable<_>`
--> src/types/tests/uri/diesel.rs:35:9
|
35 | common::assert_sql_conversion(&conn, test_uri::table, &TestUri { id: u })
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`tickets`)
= note: required because of the requirements on the impl of `diesel::Insertable<_>` for `(&(_, _, _, _, _), &_, &_, &_, &_)`
= note: required because of the requirements on the impl of `diesel::Insertable<_>` for `&((_, _, _, _, _), _, _, _, _)`
= note: required because of the requirements on the impl of `diesel::Insertable<_>` for `(&((_, _, _, _, _), _, _, _, _), &_, &_, &_, &_)`
= note: required because of the requirements on the impl of `diesel::Insertable<_>` for `&(((_, _, _, _, _), _, _, _, _), _, _, _, _)`
Sorry if I misunderstand some basic stuff, I am pretty new to rust.
I will be glad of any help.
Thanks!