+
Skip to content

sea-orm-cli: allow skipping impl ActiveModelBehavior for generated entities #1947

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

Closed

Conversation

waynr
Copy link
Contributor

@waynr waynr commented Oct 30, 2023

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 #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.

@waynr
Copy link
Contributor Author

waynr commented Oct 30, 2023

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.

@dave42w
Copy link

dave42w commented Oct 30, 2023

I think this is an excellent solution.

@waynr
Copy link
Contributor Author

waynr commented Oct 30, 2023

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

@tyt2y3
Copy link
Member

tyt2y3 commented Oct 31, 2023

The implementation looks good, and this feature is definitely useful!

@jondot
Copy link
Contributor

jondot commented Nov 27, 2023

Hi this great, much needed, can we merge this?

@tyt2y3
Copy link
Member

tyt2y3 commented Nov 27, 2023

@waynr do you have anything to amend? I can probably merge it as is

@LockedThread
Copy link

Any updates?

@waynr
Copy link
Contributor Author

waynr commented Jul 10, 2024

Oh I don't have any additional changes. Sorry, I lost track of this after I started a new job earlier this year.

@waynr waynr force-pushed the allow-skipping-impl-ActiveModleBehavior branch from 4e74dde to c512541 Compare July 10, 2024 20:55
@waynr
Copy link
Contributor Author

waynr commented Jul 10, 2024

I've rebased onto master branch and resolved the merge conflict so this should be ready to merge.

@CloverOS
Copy link

CloverOS commented Oct 8, 2024

When will it be updated? I really need this.

@@ -1667,6 +1706,29 @@ mod tests {
})
.to_string()
);
assert_eq!(
>>>>>>> 4e74dde0 (sea-orm-cli: allow skipping impl ActiveModelBehavior for generated entities)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several merge artifacts throughout this PR that should be cleaned up beforehand - but it would be great to see this merged in soon!

@TheSamsa
Copy link
Contributor

TheSamsa commented Feb 3, 2025

If nobody minds I created a copy of the original PR, since there was no progression.
I do not intend to steal anything, it is the work of @waynr he deserves the credit.
The reason why I copied this is, because there was no progress since october 2024.
Here is the PR: #2487

@tyt2y3
Copy link
Member

tyt2y3 commented Feb 22, 2025

closed in favor of #2487

thank you all

@tyt2y3 tyt2y3 closed this Feb 22, 2025
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

Successfully merging this pull request may close these issues.

8 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载