New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diesel + chrono #974

Closed
Fuckoffee opened this Issue Jun 28, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@Fuckoffee

Fuckoffee commented Jun 28, 2017

Error:

error[E0277]: the trait bound chrono::DateTime<chrono::Local>: diesel::types::FromSqlRow<diesel::types::Time, diesel::pg::Pg> is not satisfied
--> src/impulse\handlers\index.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:
<chrono::DateTimechrono::UTC as diesel::types::FromSqlRow<diesel::types::Timestamptz, DB>>
= 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/impulse\handlers\index.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?

@adwhit

This comment has been minimized.

adwhit commented Jun 28, 2017

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.

@Fuckoffee

This comment has been minimized.

Fuckoffee commented Jun 28, 2017

@adwhit Thank you so much, it works!

@killercup killercup added the question label Jun 28, 2017

@killercup

This comment has been minimized.

Member

killercup commented Jun 28, 2017

Thanks, @adwhit!

@killercup killercup closed this Jun 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment