You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I would like to implement a smoother API for the functions query_with and query_as_with.
When using the query macro query! it is not necessary to call bind and the arguments to the database can be input directly:
let res = query!("SELECT * FROM mytable WHERE col_a = $1 AND col_b = $2", var_a, var_b).fetch_all(pool).await?;
But using the regular functions it is necessary to call bind multiple times:
let res = query("SELECT * FROM mytable WHERE col_a = $1 AND col_b = $2").bind(var_a).bind(var_b).fetch_all(pool).await?;
Instead I want to use the query_with function:
let res = query_with("SELECT * FROM mytable WHERE col_a = $1 AND col_b = $2", (var_a, var_b)).fetch_all(pool).await?;
The query_with function is public but the necessary trait
A: IntoArguments<'s, <AnyStatement<'q> as Statement<'q>>::Database>,
is hard to satisfy. I propose to impl IntoArguments for tuples of various sizes. This allows easy usage with query_with and query_as_with.
I could code and test the change but would need help or instructions using github. This is my first time on this platform.
Beta Was this translation helpful? Give feedback.
All reactions