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

Cannot use nullable datetime type in MySQL #1443

Closed
Martin1887 opened this Issue Dec 31, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@Martin1887

Martin1887 commented Dec 31, 2017

Setup

Versions

  • Rust: rustc 1.24.0-nightly (7eb64b86c 2017-12-20)
  • Diesel: 0.99.0
  • Database: mariadb 10.2.9
  • Fedora 27

Feature Flags

  • diesel: mysql
  • diesel_codegen:

Problem Description

I have a datetime field in a table and the schema generated with print_schema does not compile because Datetime does not implement the trait diesel::types::NotNull.

What are you trying to accomplish?

Establish connection.

What is the expected output?

Successful compilation.

What is the actual output?

(...)
error[E0277]: the trait bound `diesel::types::Datetime: diesel::types::NotNull` is not satisfied
   --> src/web/db/schema.rs:94:1
    |
94  | / table! {
95  | |     users (id) {
96  | |         id -> Integer,
97  | |         name -> Varchar,
...   |
106 | |     }
107 | | }
    | |_^ the trait `diesel::types::NotNull` is not implemented for `diesel::types::Datetime`
    |
    = note: required by `diesel::types::Nullable`
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z      external-macro-backtrace for more info)

error: aborting due to 5 previous errors

error: Could not compile `numismatico_animal`.

Are you seeing any additional errors?

No.

Steps to reproduce

This is the generated table! macro.

table! {
    users (id) {
        id -> Integer,
        name -> Varchar,
        last_name -> Varchar,
        email -> Varchar,
        password -> Binary,
        is_admin -> Bool,
        language_id -> Varchar,
        verified -> Bool,
        verification_code -> Nullable<Binary>,
        verification_code_expiration_date -> Nullable<Datetime>,
    }
}

Thanks and regards.

@sgrif

This comment has been minimized.

Member

sgrif commented Dec 31, 2017

This was fixed in #1380 which was released in 1.0.0-rc1. We need to backport this to 0.99. In the mean time you can enable the Chrono feature to work around this

@Martin1887

This comment has been minimized.

Martin1887 commented Jan 1, 2018

Thanks, the issue can be closed then.

@Martin1887 Martin1887 closed this Jan 1, 2018

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