I have code that is attempting to pass an array of chrono::DateTime values to a stored procedure in postgres.
let stmt = connection.prepare_cached("call proc($1)").await.unwrap();
if let Ok(_) = connection.execute(&stmt, &[&array]).await {
info!("worked");
} else {
error!("error");
}
but I am getting this error:
[Error { kind: ToSql(2), cause: Some(WrongType { postgres: TimestampArray, rust: "&[chrono::datetime::DateTime<chrono::offset::utc::Utc>]" }) }
2
Answers
@pgzlan was correct. change from chrono::DateTime to NaiveDateTime worked.
Based on the error, it’s probably a mismatch between the Rust type and the PostgreSQL type when attempting to pass an array of chrono::DateTime values to a stored procedure.
You can try converting it before passing it