Skip to content
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

Support for sql type DATE #206

Closed
alexandrelegent opened this issue Sep 27, 2021 · 1 comment · Fixed by #207
Closed

Support for sql type DATE #206

alexandrelegent opened this issue Sep 27, 2021 · 1 comment · Fixed by #207
Assignees

Comments

@alexandrelegent
Copy link

Hi,
I will be great to have the support of the sql type DATE in the library.
I imagine this one will be done with chrono::NaiveDate since it's the one that is used in the documentation.

To give my own example, I have a model Rate which have a simple date:

use chrono::NaiveDate;
use sea_orm::entity::prelude::*;
use sea_orm::DeriveEntityModel;

#[derive(Debug, Clone, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "currency_exchange_rate")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub currency_exchange_rate_id: i64,
    pub from_currency: String,
    pub to_currency: String,
    pub rate_date: NaiveDate,
    pub rate: f64,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}

But this implementation give me a compile error:

error[E0277]: the trait bound `NaiveDate: TryGetable` is not satisfied
  --> src/rates/mod.rs:11:35
   |
11 | #[derive(Debug, Clone, PartialEq, DeriveEntityModel)]
   |                                   ^^^^^^^^^^^^^^^^^ the trait `TryGetable` is not implemented for `NaiveDate`
   |
   = note: this error originates in the derive macro `DeriveEntityModel` (in Nightly builds, run with -Z macro-backtrace for more info)
@tyt2y3
Copy link
Member

tyt2y3 commented Oct 1, 2021

0.2.4

arpancodes pushed a commit to arpancodes/sea-orm that referenced this issue Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants