-
Notifications
You must be signed in to change notification settings - Fork 214
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
introspection: merge index+relation introspection and reintrospection #3346
Conversation
6c60e3c
to
90255a4
Compare
introspection-engine/connectors/sql-introspection-connector/src/introspection_helpers.rs
Show resolved
Hide resolved
6642372
to
bb84f7a
Compare
bb84f7a
to
8daf79a
Compare
introspection-engine/connectors/sql-introspection-connector/src/introspection.rs
Show resolved
Hide resolved
8daf79a
to
e1f5da9
Compare
6dee8ca
to
b543507
Compare
introspection-engine/connectors/sql-introspection-connector/src/calculate_datamodel.rs
Outdated
Show resolved
Hide resolved
.filter(|table| is_prisma_1_point_1_or_2_join_table(*table) || is_prisma_1_point_0_join_table(*table)) | ||
.map(|table| table.name()[1..].to_string()) | ||
.collect(); | ||
fn introspect_models(datamodel: &mut Datamodel, ctx: &mut Context<'_>) { |
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.
This function should get its own module. I didn't do that to avoid a larger diff, but it is coming.
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.
Looks good and I love we removed a lot of code. Left in a few comments, let's have a chat if you disagree with any of them.
introspection-engine/connectors/sql-introspection-connector/src/calculate_datamodel.rs
Outdated
Show resolved
Hide resolved
introspection-engine/connectors/sql-introspection-connector/src/calculate_datamodel.rs
Outdated
Show resolved
Hide resolved
introspection-engine/connectors/sql-introspection-connector/src/calculate_datamodel.rs
Outdated
Show resolved
Hide resolved
introspection-engine/connectors/sql-introspection-connector/src/introspection.rs
Outdated
Show resolved
Hide resolved
use sql_schema_describer as sql; | ||
use std::collections::{HashMap, HashSet}; | ||
|
||
pub(super) fn introspect_inline_relations(datamodel: &mut psl::dml::Datamodel, ctx: &mut super::Context<'_>) { |
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.
This is quite verbose. I think it would be nice to split, but if that's impractical, perhaps an overview comment here explaining what's going on in this function might be enough.
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 wrote a doc comment. Beyond porting the existing code, we'll probably want to do something a bit more principled with relation and field names at some point, as that is what causes a lot of the verbosity in this function.
...spection-engine/connectors/sql-introspection-connector/src/introspection/inline_relations.rs
Show resolved
Hide resolved
...spection-engine/connectors/sql-introspection-connector/src/introspection/inline_relations.rs
Outdated
Show resolved
Hide resolved
introspection-engine/introspection-engine-tests/tests/re_introspection/mod.rs
Show resolved
Hide resolved
38424c1
to
6fc9965
Compare
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.
👍
6fc9965
to
bffd935
Compare
Changes: - Prisma 1 join tables did not get an `@relation("...")` attribute with an explicit name if they were not ambiguous, before this PR. This means migrate and client would have missed them. - The criteria for considering a relation ambiguous got more agressive. Every relation between two models that have more than one relation between them is now considered ambiguous and gets named accordingly. This should fix the relation introspection regressions introduced in #3346 closes https://github.com/prisma/schema-team/issues/354
Changes: - Prisma 1 join tables did not get an `@relation("...")` attribute with an explicit name if they were not ambiguous, before this PR. This means migrate and client would have missed them. - The criteria for considering a relation ambiguous got more agressive. Every relation between two models that have more than one relation between them is now considered ambiguous and gets named accordingly. This should fix the relation introspection regressions introduced in #3346 closes https://github.com/prisma/schema-team/issues/354
Changes: - Prisma 1 join tables did not get an `@relation("...")` attribute with an explicit name if they were not ambiguous, before this PR. This means migrate and client would have missed them. - The criteria for considering a relation ambiguous got more agressive. Every relation between two models that have more than one relation between them is now considered ambiguous and gets named accordingly. This should fix the relation introspection regressions introduced in #3346 closes https://github.com/prisma/schema-team/issues/354
Changes: - Prisma 1 join tables did not get an `@relation("...")` attribute with an explicit name if they were not ambiguous, before this PR. This means migrate and client would have missed them. - The criteria for considering a relation ambiguous got more agressive. Every relation between two models that have more than one relation between them is now considered ambiguous and gets named accordingly. This should fix the relation introspection regressions introduced in #3346 closes https://github.com/prisma/schema-team/issues/354
Changes: - Prisma 1 join tables did not get an `@relation("...")` attribute with an explicit name if they were not ambiguous, before this PR. This means migrate and client would have missed them. - The criteria for considering a relation ambiguous got more agressive. Every relation between two models that have more than one relation between them is now considered ambiguous and gets named accordingly. This should fix the relation introspection regressions introduced in #3346 closes https://github.com/prisma/schema-team/issues/354
Changes: - Prisma 1 join tables did not get an `@relation("...")` attribute with an explicit name if they were not ambiguous, before this PR. This means migrate and client would have missed them. - The criteria for considering a relation ambiguous got more agressive. Every relation between two models that have more than one relation between them is now considered ambiguous and gets named accordingly. This should fix the relation introspection regressions introduced in #3346 closes https://github.com/prisma/schema-team/issues/354
introspection: merge indexes+relations introspection and reintrospection
The path to multiSchema introspection we started on begins with a
refactoring aiming at merging introspection and reintrospection into one
step, and removing all DML usage from the introspection engine. This is
a part of it. See the following past PRs for more context:
#3338 and
#3333.