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(validation): referentialIntegrity and relationMode attributes cannot be used together #3340

Merged

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Oct 27, 2022

Before this PR, the following schema was considered valid:

datasource db {
  provider = "sqlite"
  url = "..."
  relationMode = "prisma" // we take relationMode in priority
  referentialIntegrity = "foreignKeys" // is ignored
}

This PR makes it invalid, as only one attribute between relationMode or referentialIntegrity (or none) should be used.
The validation error is:

The referentialIntegrity and relationMode attributes cannot be used together. Please use only relationMode instead.

Closes prisma/prisma#15735.

@jkomyno jkomyno requested a review from a team as a code owner October 27, 2022 09:08
@jkomyno jkomyno added this to the 4.6.0 milestone Oct 27, 2022
@jkomyno
Copy link
Contributor Author

jkomyno commented Oct 27, 2022

Follow-up (@Jolg42, @tomhoule): we can probably create a VSCode quick action to:

  • remove referentialIntegrity in favor of relationMode if both attributes exist
  • rename referentialIntegrity into relationMode if only the referentialIntegrity attribute exists

However, I'd need a couple of directions to achieve that.

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.

looks good to me 👍

@jkomyno jkomyno merged commit 190c3eb into main Oct 27, 2022
@jkomyno jkomyno deleted the feat/referential-integrity-and-relation-mode-cannot-cooccur branch October 27, 2022 10:23
@janpio
Copy link
Member

janpio commented Nov 2, 2022

Did this quick action suggestion get created as an issue @jkomyno? If not, please do so or this will be forgotten.

@jkomyno
Copy link
Contributor Author

jkomyno commented Nov 3, 2022

Tracked the quick action suggestion here: prisma/language-tools#1276

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 validation for datasource property referentialIntegrity & relationMode, so only one can be set.
3 participants