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

Chrono DateTime<UTC> trait exception #702

Closed
arnau opened this Issue Feb 14, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@arnau

arnau commented Feb 14, 2017

Hello, today I started migrating from diesel 0.9 on Rust 1.15 nightly to diesel 0.10 on Rust 1.15 stable. Right now I'm trying to understand what is wrong with my usage of chrono's DateTime<UTC>. I tried to replicate the error modifying the getting started example. The error below corresponds to this: arnau@bbdaad8

In short:

  • Added chrono 0.3.
  • Enabled feature "chrono".
  • Added a new column created_at TIMESTAMP WITH TIME ZONE.
  • Add the created_at field to the Post model.

The error:

$ cargo build
warning: unused manifest key: package.categories
   Compiling chrono_example v0.1.0 (file:///Users/arnau/kitchen/other/diesel/examples/chrono_example)
error[E0277]: the trait bound `chrono::DateTime<chrono::UTC>: diesel::types::FromSqlRow<diesel::types::Nullable<diesel::types::Timestamptz>, diesel::pg::Pg>` is not satisfied
  --> src/lib.rs:34:10
   |
34 |         .get_result(conn)
   |          ^^^^^^^^^^ the trait `diesel::types::FromSqlRow<diesel::types::Nullable<diesel::types::Timestamptz>, diesel::pg::Pg>` is not implemented for `chrono::DateTime<chrono::UTC>`
   |
   = help: the following implementations were found:
   = help:   <chrono::DateTime<chrono::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::Bool, diesel::types::Nullable<diesel::types::Timestamptz>), diesel::pg::Pg>` for `(i32, std::string::String, std::string::String, bool, chrono::DateTime<chrono::UTC>)`
   = note: required because of the requirements on the impl of `diesel::Queryable<(diesel::types::Integer, diesel::types::Text, diesel::types::Text, diesel::types::Bool, diesel::types::Nullable<diesel::types::Timestamptz>), diesel::pg::Pg>` for `models::Post`

Any ideas why this is happening?

Thanks!


Rust version: rustc 1.15.1 (021bd294c 2017-02-08)
OS: macOS 10.12.3 (Sierra)

@Eijebong

This comment has been minimized.

Member

Eijebong commented Feb 14, 2017

Yeah, you should use the master branch of diesel, use chrono 0.2 or wait for 0.11.

Since the migration to chrono 0.3 was a breaking change, it wasn't released in 0.10.x

See #648

@arnau

This comment has been minimized.

arnau commented Feb 14, 2017

Ah! Thanks!

@arnau arnau closed this Feb 14, 2017

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