Skip to content

Cannot serialize time::OffsetDateTime or time::PrimitiveDateTime properly #264

@tgrushka

Description

@tgrushka

I just switched from sqlx to cornucopia and want to love it, but it doesn't seem to allow any control over serialization without basically wrapping and rewriting code for all structs.

It just serializes timestamp with/without time zone into an array. And serde does not allow changing it without overriding each and every single field.

Cornucopia only generates the following for structs:
#[derive(serde::Serialize, Debug, Clone, PartialEq)]

But it does not seem to allow annotating fields with #[serialize(with = "...") etc. without changing the generated cornucopia.rs file, which gets deleted and re-recreated every time.

How then can I serialize/deserialize proper date time formats into standards such as ISO-8601 which the rest of the world is using?

Might as well use the CLI, generate the structs, then have to update them manually every time the database is altered?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions