I am working on a rust project where I am working with tokio postgres. I have a table by name of DATA that has two columns "id" and "opt". I have the data hitting the query as two inputs where one is a String and the other is an Option.
Following tokio postges conventions, I am having to call the client with the help of the source code provided below.I am using COALESCE to check if second parameter is NULL on the sql query and this way I am making the SQL query compact.
let rows = client.query("SELECT * FROM DATA WHERE id = $1 AND opt = COALESCE(opt, $2)", &[&input1, &input2)]).await?;
I am getting this error when I perform a cargo build
.
expected `&dyn ToSql + Sync`, found enum `Result`
Can this error be mitigated from Rust?