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

Mark primary key columns as unique in sea-orm-codegen #2236

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SZenglein
Copy link
Contributor

PR Info

This is a relatively simple change where sea-orm-cli did not mark primary key columns as unique, resulting in a has_many relation where a has_one would be correct. Issue #1884 offers a complete example where the problem occurs.

I only tested this for SQLite, but it should be pretty universal.

Maybe related: #1629
Fixes: #1884

New Features

None

Bug Fixes

sea-orm-cli no longer incorrectly assumes primary key columns as non-unique.

Breaking Changes

Code generation will be different in some cases (has_many replaced by has_one).

Copy link
Member

@billy1624 billy1624 left a comment

Choose a reason for hiding this comment

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

Hey @SZenglein, thanks for the PR. Sorry, I don't think this solve the root cause of the issue. I just made a PR, #2254, would you like to take a look and try it?

Install sea-orm-cli and try it on your local machine:

cargo install sea-orm-cli --force --git https://github.com/SeaQL/sea-orm --branch cli-gen-has-one-relation

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.

has_one relation is not recognized with primary foreign key (class table inheritance)
2 participants