Diesel: Diesel + chrono

Created on 28 Jun 2017  路  3Comments  路  Source: diesel-rs/diesel

Error:

error[E0277]: the trait bound chrono::DateTime<chrono::Local>: diesel::types::FromSqlRow<diesel::types::Time, diesel::pg::Pg> is not satisfied
--> src/impulsehandlersindex.rs:15:10
|
15 | .load::(&conn)
| ^^^^ the trait diesel::types::FromSqlRow<diesel::types::Time, diesel::pg::Pg> is not implemented for chrono::DateTime<chrono::Local>
|
= help: the following implementations were found:
as diesel::types::FromSqlRow>
= note: required because of the requirements on the impl of diesel::types::FromSqlRow<(diesel::types::Integer, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Time, diesel::types::Bool), diesel::pg::Pg> for (i32, std::string::String, std::string::String, std::string::String, std::string::String, chrono::DateTime<chrono::Local>, bool)
= note: required because of the requirements on the impl of diesel::Queryable<(diesel::types::Integer, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Time, diesel::types::Bool), diesel::pg::Pg> for entities::user_entities::User
error[E0277]: the trait bound r2d2::PooledConnection<r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>>: diesel::Connection is not satisfied
--> src/impulsehandlersindex.rs:15:10
|
15 | .load::(&conn)
| ^^^^ the trait diesel::Connection is not implemented for r2d2::PooledConnection<r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>>
error: aborting due to previous error(s)

Cargo.toml dependencies

[dependencies]
diesel = { version = "0.12", features = ["postgres", "chrono"] }
diesel_codegen = { version = "0.12", features = ["postgres"] }
rocket = "0.2"
rocket_codegen = "0.2"
rocket_contrib = "0.2"
r2d2 = "0.7"
r2d2-diesel = "0.12"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
chrono = { version = "0.3", features = ["serde", "rustc-serialize"] }

Structure

[derive(Queryable, Clone, Associations, Debug)]

pub struct User {
pub id: i32,
pub login: String,
pub email: String,
pub password: String,
pub salt: String,
pub date_of_reg: chrono::DateTime,
pub is_active: bool,
}

What could be the problem?

question

Most helpful comment

Just a guess -
According to the docs, diesel::types::Time can only be converted to/from chrono::NaiveTime, whereas you are attempting to convert chrono::DateTime.

All 3 comments

Just a guess -
According to the docs, diesel::types::Time can only be converted to/from chrono::NaiveTime, whereas you are attempting to convert chrono::DateTime.

@adwhit Thank you so much, it works!

Thanks, @adwhit!

Was this page helpful?
0 / 5 - 0 ratings