Skip to content

MySQL: [[NOT] ENFORCED] in CHECK constraint #1870

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

Merged
merged 3 commits into from
Jun 7, 2025

Conversation

MohamedAbdeen21
Copy link
Contributor

Add support for MySQL's [[NOT] ENFORCED] option for CHECK constraints.

docs: https://dev.mysql.com/doc/refman/8.4/en/create-table.html

@@ -8134,7 +8134,19 @@ impl<'a> Parser<'a> {
self.expect_token(&Token::LParen)?;
let expr = Box::new(self.parse_expr()?);
self.expect_token(&Token::RParen)?;
Ok(Some(TableConstraint::Check { name, expr }))

let enforced = match dialect_of!(self is GenericDialect | MySqlDialect) {
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 can have the parser always accept the NOT ENFORCED keywords if they show up in the statement? Otherwise we'd want to turn this into a dialect method instead of using the dialect_of macro but that feels like it might not be worth it in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated and rebased on main

@MohamedAbdeen21 MohamedAbdeen21 force-pushed the mysql-enforced-constraint branch from 927aefc to 20646fc Compare June 7, 2025 00:52
Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @MohamedAbdeen21!
cc @alamb

@iffyio iffyio merged commit 84c3a1b into apache:main Jun 7, 2025
9 checks passed
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.

2 participants