-
Notifications
You must be signed in to change notification settings - Fork 212
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
feat(psl): add deprecation warning for the "referentialIntegrity" attribute #3449
Merged
jkomyno
merged 2 commits into
main
from
feat/deprecation-warning-referential-integrity-attr
Nov 28, 2022
Merged
Changes from 1 commit
Commits
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
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
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 |
---|---|---|
|
@@ -641,35 +641,6 @@ fn relation_mode_default() { | |
assert_eq!(config.relation_mode(), Some(RelationMode::ForeignKeys)); | ||
} | ||
|
||
#[test] | ||
fn relation_mode_and_referential_integrity_cannot_cooccur() { | ||
let schema = indoc! {r#" | ||
datasource ps { | ||
provider = "sqlite" | ||
url = "sqlite" | ||
relationMode = "prisma" | ||
referentialIntegrity = "foreignKeys" | ||
} | ||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
"#}; | ||
Comment on lines
-644
to
-656
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to |
||
|
||
let config = parse_config(schema); | ||
let error = config.unwrap_err(); | ||
|
||
let expectation = expect![[r#" | ||
[1;91merror[0m: [1mThe `referentialIntegrity` and `relationMode` attributes cannot be used together. Please use only `relationMode` instead.[0m | ||
[1;94m-->[0m [4mschema.prisma:5[0m | ||
[1;94m | [0m | ||
[1;94m 4 | [0m relationMode = "prisma" | ||
[1;94m 5 | [0m [1;91mreferentialIntegrity = "foreignKeys"[0m | ||
[1;94m 6 | [0m} | ||
[1;94m | [0m | ||
"#]]; | ||
expectation.assert_eq(&error); | ||
} | ||
|
||
fn load_env_var(key: &str) -> Option<String> { | ||
std::env::var(key).ok() | ||
} |
12 changes: 12 additions & 0 deletions
12
...tests/validation/attributes/relation_mode/referential_integrity_attr_is_deprecated.prisma
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,12 @@ | ||
datasource db { | ||
provider = "sqlite" | ||
url = "sqlite" | ||
referentialIntegrity = "foreignKeys" | ||
} | ||
// [1;93mwarning[0m: [1mThe `referentialIntegrity` attribute is deprecated. Please use `relationMode` instead. Learn more at https://pris.ly/d/relation-mode[0m | ||
// [1;94m-->[0m [4mschema.prisma:4[0m | ||
// [1;94m | [0m | ||
// [1;94m 3 | [0m url = "sqlite" | ||
// [1;94m 4 | [0m [1;93mreferentialIntegrity = "foreignKeys"[0m | ||
// [1;94m 5 | [0m} | ||
// [1;94m | [0m |
13 changes: 13 additions & 0 deletions
13
...on/attributes/relation_mode/relation_mode_and_referential_integrity_cannot_cooccur.prisma
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,13 @@ | ||
datasource db { | ||
provider = "sqlite" | ||
url = "sqlite" | ||
relationMode = "prisma" | ||
referentialIntegrity = "foreignKeys" | ||
} | ||
// [1;91merror[0m: [1mThe `referentialIntegrity` and `relationMode` attributes cannot be used together. Please use only `relationMode` instead.[0m | ||
// [1;94m-->[0m [4mschema.prisma:5[0m | ||
// [1;94m | [0m | ||
// [1;94m 4 | [0m relationMode = "prisma" | ||
// [1;94m 5 | [0m [1;91mreferentialIntegrity = "foreignKeys"[0m | ||
// [1;94m 6 | [0m} | ||
// [1;94m | [0m |
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.
Moved the code down here to the new
get_and_validate_relation_mode_value
andvalidate_allowed_relation_mode_settings
closures, as they're used both when only therelationMode
attribute is used or when only thereferentialIntegrity
attribute is usedThere 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 think we are mixing concerns and making the code more complicated here. Would something much simpler like
if args.contains("referentialIntegrity") { ... push the warning here ... }
at the beginning of the function, before thematch
works. It would emit two warnings in case you defined both, but that's fine.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.
Ok, done