-
|
Hello, Schema: CREATE TABLE test(
id SERIAL NOT NULL,
description TEXT NOT NULL,
deleted_at TIMESTAMPTZ NULL DEFAULT NULL,
PRIMARY KEY (id),
)Rust struct: struct Test {
id: i32,
description: String,
deleted_at: Option<chrono::DateTime<Local>>,
}When I try to use the given struct in a sqlx::query_as!(
Test,
r#"
SELECT * FROM test WHERE id = $1
"#,
id
)I'll encounter the following compile error : error[E0277]: the trait bound `std::option::Option<chrono::DateTime<chrono::Local>>: std::convert::From<std::option::Option<chrono::DateTime<chrono::Utc>>>` is not satisfiedThe error will be gone by using Thank you beforehand |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
For future visitors of this Q&A. The problem can be solved by overriding column type at select query. So instead of SELECT * FROM test WHERE id = $1You should use SELECT id,description, deleted_at as "deleted_at: DateTime<Local>" FROM test WHERE id = $1 |
Beta Was this translation helpful? Give feedback.
For future visitors of this Q&A. The problem can be solved by overriding column type at select query.
So instead of
You should use