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

[cli] generate Related for m-to-n relation #1075

Merged
merged 1 commit into from
Oct 26, 2022
Merged

Conversation

billy1624
Copy link
Member

@billy1624 billy1624 commented Sep 26, 2022

PR Info

Fixes

  • The old logic of determining a m-to-n relation somehow require the relation to be a composite foreign key. However, this clearly not a must. So, I updated to logic to only require the intermediate table of a m-to-n relation to be with
    • Exactly 2 foreign keys
    • A primary key formed by exactly 2 columns
    • Number of primary key equals to number of column

@billy1624 billy1624 self-assigned this Sep 26, 2022
@billy1624 billy1624 marked this pull request as ready for review September 26, 2022 07:59
@tyt2y3
Copy link
Member

tyt2y3 commented Oct 9, 2022

Interesting. I don't have much knowledge here, but I vaguely remember a discussion around 'how to infer a many-to-many relationship' was made a long while ago.

Copy link
Member

@tyt2y3 tyt2y3 left a comment

Choose a reason for hiding this comment

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

Approve if it is only going to relax the requirement

@tyt2y3
Copy link
Member

tyt2y3 commented Oct 16, 2022

Feel free to merge

@kandrelczyk
Copy link

Hi @billy1624 ,
I've just came across this issue in my project. I have m-to-n relation that is not generated correctly by cli. Any idea when this will be merged?

@billy1624
Copy link
Member Author

Hey @kandrelczyk, I'll merge this now and this will be release on our next patch version.

@billy1624 billy1624 merged commit a3fb8e8 into master Oct 26, 2022
@billy1624 billy1624 deleted the codegen-m-to-n-related branch October 26, 2022 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Generate m-to-m relations with sea-orm-cli
3 participants