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

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

Open
tgrushka opened this issue Dec 17, 2024 · 0 comments
Open

Comments

@tgrushka
Copy link

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?

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

No branches or pull requests

1 participant