-
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): remove 'SetDefault' support on MySQL #3363
Conversation
let additional_info = match (action, connector.provider_name()) { | ||
(ReferentialAction::SetDefault, "mysql") => Some(formatdoc! { | ||
r#" | ||
. `{set_default}` is invalid for {provider} when using `relationMode = \"foreignKeys\"`, as {provider} does not support the `SET DEFAULT` referential action. |
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 also happens when not relationMode
is set. Can we take that into account in the error message wording?
Also: MySQL docs say it does support it. How can we make this clearer? "... does not actually support properly ..." is probably a bit too salty :D
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.
Technically the complementary of relationMode = "prisma"
is indeed relationMode = "foreignKeys"
. What's your suggestion here? Should I just get rid of the when using...
part?
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.
Help with the message wording is welcomed :)
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.
No, for the user there is no relationMode at all in use in most cases.
This could work:
"when using" => "(by default or when using relationMode=foreignKeys
)"
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 don't think we should have a specific message for this, it reads like something generic and it should be (at first sight).
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.
How about:
Invalid referential action:
SetDefault
. Allowed values: (Cascade
,Restrict
,NoAction
,SetNull
). Starting fromPrisma v4.6.0
, we disabledSetDefault
on MySQL (when usingrelationMode = "foreignKeys"
or when not using referential integrity at all), as MySQL does not natively support theSET DEFAULT
referential action. Learn more at ..."
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.
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.
We should not include version information in error messages.
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.
The second bit of the error message is because we differ from what MySQL supports there @tomhoule. People can have this in their database, and after Introspection they will get this and then get a validation error. This second sentence gives the necessary context to be able to understand and then links to documentation that goes deeper into that.
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.
(We'll talk about this in our team sync today)
(ReferentialAction::SetDefault, "mysql") => Some(formatdoc! { | ||
r#" | ||
. `{set_default}` is invalid for {provider} when using `relationMode = \"foreignKeys\"`, as {provider} does not support the `SET DEFAULT` referential action. | ||
Learn more at https://github.com/prisma/prisma/issues/11498 |
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 should already be a pris.ly link that redirects to this URL, so we can fix this later without a release. Jsut create the shortlink by adding to the vercel config file there via a PR.
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 haven't ever done that, could you please post here a link to a pris.ly README or something? I'll address that on Monday.
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.
expected_validation.assert_eq(&validation.err().unwrap()); | ||
|
||
Ok(()) | ||
} |
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.
We've always strived to make introspected output be valid for any existing database, this is a departure.
@@ -151,8 +152,21 @@ pub(super) fn referential_actions(field: RelationFieldWalker<'_>, ctx: &mut Cont | |||
let msg_foreign_keys = |action: ReferentialAction| { | |||
let allowed_actions = connector.referential_actions(); | |||
|
|||
let additional_info = match (action, connector.provider_name()) { | |||
(ReferentialAction::SetDefault, "mysql") => Some(formatdoc! { |
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.
No need to change it now, but for future PRs: we try hard to avoid connector-specific code in the core. This should be in the MySQL connector.
As discussed on Zoom with @janpio, this PR is no longer needed. We'll resort to warnings rather than errors in order to avoid scenarios where users that do not control their database schema (which may incorrectly have |
See the internal document for reference.
Validation message:
TODO:
onDelete: setDefault
prisma#11498Contributes to prisma/prisma#11498.