Skip to content

the trait rocket::request::FromFormValue<'_> is not implemented for models::chrono::NaiveDate #602

@luisvonmuller

Description

@luisvonmuller

Setup

Versions

  • Rust:
    rustc 1.25.0-nightly

  • Rocket:
    0.3.8 (Apr 07, 2018)

  • Diesel:
    version = "1.1.0"

  • Database:
    PGsql 10.3

  • Operating System
    Windows 10 Fall creators update

Feature Flags

chrono = { version = "0.4", features = ["serde"] }

  • diesel:
    diesel = { version = "1.1.0", features = ["postgres", "chrono", "large-tables" ] }

Problem Description

I got a "NaiveDate" field at a diesel insertable struct that derives from rocket's request::FromForm and the trait bound models::chrono::NaiveDate: rocket::request::FromFormValue<'_> is not being satisfied.

#[derive(Insertable, Debug, FromForm)]
#[table_name="login"]
pub struct NewLogin {
pub username: String,
pub userpass: String,
pub creation_date: Option<self::chrono::NaiveDate>,
}

What is the expected output?

Successful compiling xD

What is the actual output?

error[E0277]: the trait bound models::chrono::NaiveDate: rocket::request::FromFormValue<'>is not satisfied --> examples\freedu\src\models.rs:116:29 | 116 | #[derive(Insertable, Debug, FromForm)] | ^^^^^^^^ the traitrocket::request::FromFormValue<'>is not implemented formodels::chrono::NaiveDate| = note: required because of the requirements on the impl ofrocket::request::FromFormValue<'_>forstd::option::Optionmodels::chrono::NaiveDate``

Steps to reproduce

  1. Create a struct with NaiveDate as a field type.
  2. Use "LanientForm" from rocket.rs to fill it.
  3. Add Derive(FromForm) to the struct;
  4. Bug.

Full code source:
https://github.com/luis-vmjr/freedu/blob/master/src/models.rs

Checklist

  • [X ] I have already looked over the issue tracker for similar issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionA question (converts to discussion)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions