SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
6.56k stars 459 forks source link

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

Open SZenglein opened 1 month ago

SZenglein commented 1 month ago

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: https://github.com/SeaQL/sea-orm/pull/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).