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

feat(psl): add deprecation warning for the "referentialIntegrity" attribute #3449

Merged
merged 2 commits into from Nov 28, 2022

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Nov 27, 2022

The referentialIntegrity attribute to set the foreignKeys|prisma settings is deprecated in favor of relationMode as of #3428.
This PR adds a validation warning when referentialIntegrity appears as a datasource attribute in a Prisma schema:

"""
The referentialIntegrity attribute is deprecated. Please use relationMode instead. Learn more at https://pris.ly/d/relation-mode
"""

Closes prisma/prisma#15689.

@jkomyno jkomyno added this to the 4.7.0 milestone Nov 27, 2022
Comment on lines -644 to -656
#[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"
}
"#};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to relation_mode_and_referential_integrity_cannot_cooccur.prisma in the validation_tests suite

Comment on lines 200 to 201
(Some((_span, rm)), None) | (None, Some((_span, rm))) => {
let integrity = match coerce::string(rm, diagnostics)? {
Copy link
Contributor Author

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 and validate_allowed_relation_mode_settings closures, as they're used both when only the relationMode attribute is used or when only the referentialIntegrity attribute is used

Copy link
Contributor

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 the match works. It would emit two warnings in case you defined both, but that's fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done

@jkomyno jkomyno marked this pull request as ready for review November 27, 2022 23:18
@jkomyno jkomyno requested a review from a team as a code owner November 27, 2022 23:18
Copy link
Member

@janpio janpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on warning message

… when it co-occurs with the "relationMode" attribute
@jkomyno jkomyno merged commit aa2457a into main Nov 28, 2022
@jkomyno jkomyno deleted the feat/deprecation-warning-referential-integrity-attr branch November 28, 2022 13:01
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.

Schema: add deprecation warning for datasource property referentialIntegrity (renamed to relationMode)
3 participants