clickhouse.rs icon indicating copy to clipboard operation
clickhouse.rs copied to clipboard

Please add support for `chrono::{Date, DateTime}` and friends in addition to "time".

Open keltia opened this issue 1 year ago • 2 comments

After wrestling a bit with clickhouse_rs to extract dates out of a CH table, I find out it is using types from the "time" crate. It would be nice to have support for the different types from the "chrono" crate as well, I find the latter much easier to use.

Have a chrono feature for example, serde already know how to deal with these.

Having

#[derive(Debug, Deserialize, Serialize, Row)]
pub struct Install {
    pub id: u32,
    pub site_id: u32,
    pub antenna_id: u32,
    pub start_at: DateTime<Utc>,
    pub end_at: DateTime<Utc>,
    pub comment: String,
}

would be way easier than my current

#[derive(Debug, Deserialize, Serialize, Row)]
pub struct Install {
    pub id: u32,
    pub site_id: u32,
    pub antenna_id: u32,
    #[serde(with = "clickhouse::serde::time::datetime")]
    pub start_at: OffsetDateTime,
    #[serde(with = "clickhouse::serde::time::datetime")]
    pub end_at: OffsetDateTime,
    pub comment: String,
}

Thanks.

keltia avatar May 15 '24 16:05 keltia

There's also the jiff crate now as well. Would be happy to contribute support

v3xro avatar Jul 30 '24 14:07 v3xro

This crate should support all three under features, so I'd like to accept PR. Anyway, I'm thinking about moving to jiff for my production code so that it will be implemented eventually anyway

loyd avatar Aug 18 '24 08:08 loyd

Was added in #188

slvrtrn avatar May 29 '25 20:05 slvrtrn