-
Notifications
You must be signed in to change notification settings - Fork 213
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
fix: re-introspection with @@map
and relationMode
#3335
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
be66eda
test: add tests of status quo for re-introspection with/without relat…
jkomyno 56f8422
chore: fix typos
jkomyno 19b6931
chore: fix mod imports and snapshots
jkomyno f558c2e
chore: add '_at_map_map' suffix to 'at_map_map' tests
jkomyno 97e8194
chore: update sqlite test snapshots
jkomyno f1180ed
fix: re-introspection with 'relationMode = "prisma"' on tables using …
jkomyno eb7457c
chore: merge main, fix conflicts
jkomyno e97b243
chore: fix clippy warnings
jkomyno 4a75634
chore: fix spacing in snapshot
jkomyno ade5723
chore: merge main, fix conflicts
jkomyno ac2c1c4
test: update snapshots after https://github.com/prisma/prisma-engines…
jkomyno abe4999
fix: get rid of clones in old_model_name_to_final_database_name
jkomyno File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
introspection-engine/introspection-engine-tests/tests/re_introspection/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod mssql; | ||
mod mysql; | ||
mod relation_mode; | ||
mod sqlite; | ||
mod vitess; | ||
|
||
|
4 changes: 4 additions & 0 deletions
4
introspection-engine/introspection-engine-tests/tests/re_introspection/relation_mode/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mod mssql; | ||
mod mysql; | ||
mod postgres; | ||
mod sqlite; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Any suggestion on how to avoid these clones while still being able to use the function in the following closures is well accepted.
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 wouldn't worry about it here, but you can change line 147 to
.map(|m| (m.name.as_str(), m.final_database_name()))
and the type ascription toHashMap<&str, &str>
. To optimize further, you could make the HashMap potentially a lot smaller if you.filter()
for only the models with a mapped name first — then a model missing in the map would mean the model is not remapped, which would be handled with the existing code lower down.But we shouldn't worry too much here, we're in the process of rewriting this file and the string comparisons will go away, we'll have a big map of integer identifiers for these lookups, since they happen repeatedly during introspection and reintrospection.
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.
Thanks. I have simply got rid of
.clone()
in favor of.as_str()
. I will skip other optimizations for now, as we expect this file to change significantly already