Skip to content

Commit 927aefc

Browse files
Make [[NOT] ENFORCED] common between dialects
1 parent aeb0094 commit 927aefc

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/parser/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8135,11 +8135,12 @@ impl<'a> Parser<'a> {
81358135
let expr = Box::new(self.parse_expr()?);
81368136
self.expect_token(&Token::RParen)?;
81378137

8138-
let enforced = match dialect_of!(self is GenericDialect | MySqlDialect) {
8139-
true if self.parse_keywords(&[Keyword::NOT, Keyword::ENFORCED]) => Some(false),
8140-
true if self.parse_keyword(Keyword::ENFORCED) => Some(true),
8141-
// not MySQL, or is MySQL but not specified
8142-
_ => None,
8138+
let enforced = if self.parse_keyword(Keyword::ENFORCED) {
8139+
Some(true)
8140+
} else if self.parse_keywords(&[Keyword::NOT, Keyword::ENFORCED]) {
8141+
Some(false)
8142+
} else {
8143+
None
81438144
};
81448145

81458146
Ok(Some(TableConstraint::Check {

tests/sqlparser_common.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15294,3 +15294,10 @@ fn test_open() {
1529415294
})
1529515295
);
1529615296
}
15297+
15298+
#[test]
15299+
fn check_enforced() {
15300+
all_dialects().verified_stmt(
15301+
"CREATE TABLE t (a INT, b INT, c INT, CHECK (a > 0) NOT ENFORCED, CHECK (b > 0) ENFORCED, CHECK (c > 0))",
15302+
);
15303+
}

tests/sqlparser_mysql.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,10 +4018,3 @@ fn parse_drop_index() {
40184018
_ => unreachable!(),
40194019
}
40204020
}
4021-
4022-
#[test]
4023-
fn check_enforced() {
4024-
mysql().verified_stmt(
4025-
"CREATE TABLE t (a INT, b INT, c INT, CHECK (a > 0) NOT ENFORCED, CHECK (b > 0) ENFORCED, CHECK (c > 0))",
4026-
);
4027-
}

0 commit comments

Comments
 (0)