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

Adjust legacy M:N Relation Inference #595

Merged
merged 4 commits into from Mar 20, 2020
Merged

Conversation

do4gr
Copy link
Member

@do4gr do4gr commented Mar 20, 2020

@do4gr do4gr added this to the Preview 25 milestone Mar 20, 2020
@do4gr do4gr self-assigned this Mar 20, 2020
Copy link
Contributor

@tomhoule tomhoule left a 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)
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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())
Copy link
Contributor

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().

Copy link
Member Author

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 {
Copy link
Contributor

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

Copy link
Member Author

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.

@do4gr do4gr merged commit 8a42b84 into master Mar 20, 2020
@do4gr do4gr deleted the AdjustLegacyMToNInference branch March 20, 2020 12:28
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.

Relation table for implicit m:n-relation not recognized by introspection
2 participants