Skip to content

Commit 936c2f1

Browse files
PR feedback: skip dialect methods
1 parent 6b1bc37 commit 936c2f1

4 files changed

Lines changed: 4 additions & 31 deletions

File tree

src/dialect/mod.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,20 +1060,6 @@ pub trait Dialect: Debug + Any {
10601060
fn supports_space_separated_column_options(&self) -> bool {
10611061
false
10621062
}
1063-
1064-
/// Returns true if the dialect supports `ADD <table_constraint> [NOT VALID]` in `ALTER TABLE` statements.
1065-
///
1066-
/// - [PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
1067-
fn supports_constraint_not_valid(&self) -> bool {
1068-
false
1069-
}
1070-
1071-
/// Returns true if the dialect supports `VALIDATE CONSTRAINT <constraint_name>` in `ALTER TABLE` statements.
1072-
///
1073-
/// - [PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
1074-
fn supports_validate_constraint(&self) -> bool {
1075-
false
1076-
}
10771063
}
10781064

10791065
/// This represents the operators for which precedence must be defined

src/dialect/postgresql.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,4 @@ impl Dialect for PostgreSqlDialect {
258258
fn supports_set_names(&self) -> bool {
259259
true
260260
}
261-
262-
fn supports_constraint_not_valid(&self) -> bool {
263-
true
264-
}
265-
266-
fn supports_validate_constraint(&self) -> bool {
267-
true
268-
}
269261
}

src/parser/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8477,10 +8477,7 @@ impl<'a> Parser<'a> {
84778477
pub fn parse_alter_table_operation(&mut self) -> Result<AlterTableOperation, ParserError> {
84788478
let operation = if self.parse_keyword(Keyword::ADD) {
84798479
if let Some(constraint) = self.parse_optional_table_constraint()? {
8480-
let mut not_valid = false;
8481-
if self.dialect.supports_constraint_not_valid() {
8482-
not_valid = self.parse_keywords(&[Keyword::NOT, Keyword::VALID]);
8483-
}
8480+
let not_valid = self.parse_keywords(&[Keyword::NOT, Keyword::VALID]);
84848481
AlterTableOperation::AddConstraint {
84858482
constraint,
84868483
not_valid,
@@ -8899,9 +8896,7 @@ impl<'a> Parser<'a> {
88998896
};
89008897

89018898
AlterTableOperation::ReplicaIdentity { identity }
8902-
} else if self.parse_keywords(&[Keyword::VALIDATE, Keyword::CONSTRAINT])
8903-
&& self.dialect.supports_validate_constraint()
8904-
{
8899+
} else if self.parse_keywords(&[Keyword::VALIDATE, Keyword::CONSTRAINT]) {
89058900
let name = self.parse_identifier()?;
89068901
AlterTableOperation::ValidateConstraint { name }
89078902
} else {

tests/sqlparser_postgres.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6235,7 +6235,7 @@ fn parse_ts_datatypes() {
62356235

62366236
#[test]
62376237
fn parse_alter_table_constraint_not_valid() {
6238-
match pg().verified_stmt(
6238+
match pg_and_generic().verified_stmt(
62396239
"ALTER TABLE foo ADD CONSTRAINT bar FOREIGN KEY (baz) REFERENCES other(ref) NOT VALID",
62406240
) {
62416241
Statement::AlterTable { operations, .. } => {
@@ -6262,7 +6262,7 @@ fn parse_alter_table_constraint_not_valid() {
62626262

62636263
#[test]
62646264
fn parse_alter_table_validate_constraint() {
6265-
match pg().verified_stmt("ALTER TABLE foo VALIDATE CONSTRAINT bar") {
6265+
match pg_and_generic().verified_stmt("ALTER TABLE foo VALIDATE CONSTRAINT bar") {
62666266
Statement::AlterTable { operations, .. } => {
62676267
assert_eq!(
62686268
operations,

0 commit comments

Comments
 (0)