wundergraph icon indicating copy to clipboard operation
wundergraph copied to clipboard

NaiveDateTime not converted correctly

Open mainrs opened this issue 5 years ago • 0 comments

As discussed in Gitter, I opened up this issue. However, I couldn't manage to create a reproducible example. I uploaded my code to https://github.com/SirWindfield/wundergraph_mvp. Compiling with the wg feature uses wundergraph. And in fact, it does compile here (compared to my other code where it doesn't). Not sure if the difference lies in the fact that I just create one single model compared to the whole GraphQL schema. But the compilation error prior didn't indicate that the problem originates from the schema related part.

Edit: The original model definition alongside the PostgreSQL and error:

#[derive(Clone, Debug, Identifiable, Queryable, WundergraphEntity)]
#[table_name = "pantry_items"]
pub struct PantryItem {
    pub id: i32,
    pub name: String,
    pub expires_at: chrono::naive::NaiveDateTime,
}
CREATE TABLE pantry_items(
    id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY NOT NULL,
    name VARCHAR NOT NULL,
    expires_at TIMESTAMPTZ NOT NULL
);
type mismatch resolving `<diesel::sql_types::Timestamptz as diesel::sql_types::IntoNullable>::Nullable == diesel::sql_types::Nullable<diesel::sql_types::Timestamp>`
  --> src/db/pantry_items.rs:12:49
   |
12 | #[derive(Clone, Debug, Identifiable, Queryable, WundergraphEntity)]
   |                                                 ^^^^^^^^^^^^^^^^^ expected struct `diesel::sql_types::Timestamptz`, found struct `diesel::sql_types::Timestamp`
   |
   = note: expected struct `diesel::sql_types::Nullable<diesel::sql_types::Timestamptz>`
              found struct `diesel::sql_types::Nullable<diesel::sql_types::Timestamp>`
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

mainrs avatar Mar 16 '20 21:03 mainrs