sea-orm
sea-orm copied to clipboard
sea-orm-cli: allow skipping impl ActiveModelBehavior for generated entities
This PR adds an option that enables users to skip generating the
impl ActiveModelBehavior for ActiveModel {}
by passing the --gen-impl-active-model-behavior false
flag to sea-orm-cli generate entity
.
This is intended to allow for an easy and idiomatic-for-rust alternative to https://github.com/SeaQL/sea-orm/issues/1931 which I described in more detail in a related discussion post
I don't necessarily think this should close out #1931, but I do think that the complexity of the solution described in that issue merits some consideration given the available alternative.
The current state of this PR only adds the CLI flag that maintains the current default behavior and updates EntityWriter
test cases to include the new option. If maintainers are open to this approach I'd be happy to add some new test cases to validate the false
code path.
I think this is an excellent solution.
Something I didn't realize when I opened this PR is that it may be a little problematic since it's all-or-nothing whereas it may be desirable for the empty impl blocks to exist for some of the generated entities since some ActiveModel
trait methods have ActiveModelBehavior
as a trait bound: https://docs.rs/sea-orm/latest/sea_orm/entity/trait.ActiveModelTrait.html
The implementation looks good, and this feature is definitely useful!
Hi this great, much needed, can we merge this?
@waynr do you have anything to amend? I can probably merge it as is
Any updates?
Oh I don't have any additional changes. Sorry, I lost track of this after I started a new job earlier this year.
I've rebased onto master branch and resolved the merge conflict so this should be ready to merge.