Skip to content

Commit

Permalink
relation generation check SeaQL/sea-orm#1435
Browse files Browse the repository at this point in the history
  • Loading branch information
darkmmon committed Jul 12, 2023
1 parent 5791b83 commit 980b896
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SeaORM/docs/0.12.x-CHANGELOG_temp.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ pub enum StringValueVariant {
_0x300x20123,
}
```
================================ All Changes above was being Documented ================================
* [sea-orm-cli] The implementation of `Related<R>` with `via` and `to` methods will not be generated if there exists multiple paths via an intermediate table. Like in the schema defined below - Path 1. `users <-> users_votes <-> bills`, Path 2. `users <-> users_saved_bills <-> bills` https://github.com/SeaQL/sea-orm/pull/1435
```sql
CREATE TABLE users
Expand Down Expand Up @@ -397,6 +396,7 @@ CREATE TABLE users_saved_bills
CONSTRAINT users_saved_bills_pkey PRIMARY KEY (user_id, bill_id)
);
```
================================ All Changes above was being Documented ================================
* [sea-orm-cli] fixed entity generation includes partitioned tables https://github.com/SeaQL/sea-orm/issues/1582, https://github.com/SeaQL/sea-schema/pull/105
* Fixed `ActiveEnum::db_type()` return type does not implement `ColumnTypeTrait` https://github.com/SeaQL/sea-orm/pull/1576
```rs
Expand Down
36 changes: 36 additions & 0 deletions SeaORM/docs/06-relation/03-many-to-many.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,39 @@ pub enum Relation {
Filling,
}
```

Note that the implementation of `Related<R>` with `via` and `to` methods will not be generated if there exists multiple paths via an intermediate table.

For example, in the schema defined below - Path 1. `users <-> users_votes <-> bills`, Path 2. `users <-> users_saved_bills <-> bills`
```sql
CREATE TABLE users
(
id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
email TEXT UNIQUE NOT NULL,
...
);
```
```sql
CREATE TABLE bills
(
id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
...
);
```
```sql
CREATE TABLE users_votes
(
user_id uuid REFERENCES users (id) ON UPDATE CASCADE ON DELETE CASCADE,
bill_id uuid REFERENCES bills (id) ON UPDATE CASCADE ON DELETE CASCADE,
vote boolean NOT NULL,
CONSTRAINT users_bills_pkey PRIMARY KEY (user_id, bill_id)
);
```
```sql
CREATE TABLE users_saved_bills
(
user_id uuid REFERENCES users (id) ON UPDATE CASCADE ON DELETE CASCADE,
bill_id uuid REFERENCES bills (id) ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT users_saved_bills_pkey PRIMARY KEY (user_id, bill_id)
);
```

0 comments on commit 980b896

Please sign in to comment.