This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch 
gh-readonly-queue/main/pr-2180-ed983e09c24e2e4c9d4e6d9800c6a34e615efcb8
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git

commit c8b7f7cf4281cdfff3e08e9827928662b8be8095
Author: Michael Victor Zink <[email protected]>
AuthorDate: Fri Jan 30 03:11:49 2026 -0800

    Add ENFORCED/NOT ENFORCED support for column-level CHECK constraints (#2180)
---
 src/parser/mod.rs         | 11 ++++++++++-
 tests/sqlparser_common.rs |  9 +++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 59ca4522..27631143 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -8922,11 +8922,20 @@ impl<'a> Parser<'a> {
             // since `CHECK` requires parentheses, we can parse the inner 
expression in ParserState::Normal
             let expr: Expr = self.with_state(ParserState::Normal, |p| 
p.parse_expr())?;
             self.expect_token(&Token::RParen)?;
+
+            let enforced = if self.parse_keyword(Keyword::ENFORCED) {
+                Some(true)
+            } else if self.parse_keywords(&[Keyword::NOT, Keyword::ENFORCED]) {
+                Some(false)
+            } else {
+                None
+            };
+
             Ok(Some(
                 CheckConstraint {
                     name: None, // Column-level check constraints don't have 
names
                     expr: Box::new(expr),
-                    enforced: None, // Could be extended later to support 
MySQL ENFORCED/NOT ENFORCED
+                    enforced,
                 }
                 .into(),
             ))
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index 8b0bcc12..69524ff9 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -16853,6 +16853,15 @@ fn check_enforced() {
     );
 }
 
+#[test]
+fn column_check_enforced() {
+    all_dialects().verified_stmt("CREATE TABLE t (x INT CHECK (x > 1) NOT 
ENFORCED)");
+    all_dialects().verified_stmt("CREATE TABLE t (x INT CHECK (x > 1) 
ENFORCED)");
+    all_dialects().verified_stmt(
+        "CREATE TABLE t (a INT CHECK (a > 0) NOT ENFORCED, b INT CHECK (b > 0) 
ENFORCED, c INT CHECK (c > 0))",
+    );
+}
+
 #[test]
 fn join_precedence() {
     all_dialects_except(|d| 
!d.supports_left_associative_joins_without_parens())


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to