sea-orm icon indicating copy to clipboard operation
sea-orm copied to clipboard

Add CLI option to `sea-orm-cli` to skip primary keys with serde on generation of entities

Open Witcher01 opened this issue 2 years ago • 3 comments

PR Info

  • Closes https://github.com/SeaQL/sea-orm/issues/841

Adds

  • [ ] Command line argument --skip-primary-key-deserialization to sea-orm-cli for the option to skip deserialization of primary keys with serde by adding #[serde(skip_deserialization)] to the primary key

As the comment says, this adds the option to skip serializing primary keys with serde in entities generated by sea-orm-cli. The command line flag name is a bit long, so feel free to suggest a different name for it. The implementation could use some work to feel better, so I'll take suggestions for this as well.

As of now clap doesn't treat the new argument as only being allowed to be set when --with-serde with a value other than none is used.

Witcher01 avatar Jul 06 '22 15:07 Witcher01

Right, I didn't look at the tests. This might take a bit of time

Witcher01 avatar Jul 07 '22 09:07 Witcher01

I just noticed that skipping the primary key deserialization isn't added in the expanded formats. I'll fix that and push a new commit when I'm done. ETA this evening, hopefully. I'm also adding tests for this, as I haven't done that yet.

Witcher01 avatar Aug 03 '22 08:08 Witcher01

Thanks! @Witcher01

billy1624 avatar Aug 03 '22 08:08 billy1624

I'm not finding any time to implement this. If anyone else wants to have a go at this with my changes already there, feel free to keep working on this.

Witcher01 avatar Oct 21 '22 13:10 Witcher01