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
Adjust legacy M:N Relation Inference #595
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked that a simple many-to-many relation created with the ME on this branch introspects as a many-to-many. All good 👍
&& table.indices.len() >= 1 | ||
&& table.indices.last().unwrap().columns.len() == 2 | ||
&& table.indices.last().unwrap().tpe == IndexType::Unique | ||
table.columns.len() == 2 && table.indices.len() >= 2 && shared(table) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could there be more indices on these tables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to leave this open in case people have sth like this:
Index(A)
Index(B)
Primary(A,B)
I am not aware of us doing it like this, but I wanted to leave that flexibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup sounds reasonable
.find(|column| column.name.to_lowercase() == "b") | ||
.is_some() | ||
&& table.indices.len() >= 2 | ||
&& table.columns.iter().any(|c| c.name == "id".to_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: here I think you can avoid an allocation by changing c.name
to c.name.as_str()
and removing to_string()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
&& shared(table) | ||
} | ||
|
||
fn shared(table: &Table) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick also, but I think the name could be a bit more descriptive, maybe shared_match_prisma_join_table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I adjusted it.
Fixes prisma/prisma#1885