Closed BenJeau closed 2 years ago
Just by looking at the source code, seems like enums are not treating imports the same way as entities.
Enums (https://github.com/SeaQL/sea-orm/blob/master/sea-orm-codegen/src/entity/writer.rs#L156) don't seem to care about serde whereas entities are using this function for generating imports (https://github.com/SeaQL/sea-orm/blob/master/sea-orm-codegen/src/entity/writer.rs#L231).
And as for the derives, entities take care of this here https://github.com/SeaQL/sea-orm/blob/master/sea-orm-codegen/src/entity/writer.rs#L509, whereas enums are not https://github.com/SeaQL/sea-orm/blob/master/sea-orm-codegen/src/entity/active_enum.rs#L21.
Seems like it has been forgotten unless it was intentional? I can look into creating a PR adding serde derives to enums if it is wanted in this crate.
Seems like it has been forgotten unless it was intentional?
I forgot to do so :(
I can look into creating a PR adding serde derives to enums if it is wanted in this crate.
Definitely wanted
I'm currently playing with
sea-orm
coming fromdiesel-rs
and I love it! But I ran into this error while using enums and serde, the enums do not contain any serde derives.Reproduction
With a simple PostgreSQL schema
Running the following command (same behaviour with either
serialize
,deserialize
,both
):Creates the following file with Enums that does not contain the serde derives, where the errors propagates to the users model's
kind
column.Expected Result
I would expect enums, just like models, to contain the derive.