only use in postgres

This commit is contained in:
achristmascarl 2025-06-25 14:37:22 -04:00
parent 0e174c2b05
commit b3da639810
4 changed files with 7 additions and 4 deletions

View file

@ -1064,7 +1064,7 @@ pub trait Dialect: Debug + Any {
/// Returns true if the dialect supports `ADD <table_constraint> [NOT VALID]` in `ALTER TABLE` statements.
///
/// -[PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
fn supports_constraint_not_validation(&self) -> bool {
fn supports_constraint_not_valid(&self) -> bool {
false
}

View file

@ -259,7 +259,7 @@ impl Dialect for PostgreSqlDialect {
true
}
fn supports_constraint_not_validation(&self) -> bool {
fn supports_constraint_not_valid(&self) -> bool {
true
}

View file

@ -8477,7 +8477,10 @@ impl<'a> Parser<'a> {
pub fn parse_alter_table_operation(&mut self) -> Result<AlterTableOperation, ParserError> {
let operation = if self.parse_keyword(Keyword::ADD) {
if let Some(constraint) = self.parse_optional_table_constraint()? {
let not_valid = self.parse_keywords(&[Keyword::NOT, Keyword::VALID]);
let mut not_valid = false;
if self.dialect.supports_constraint_not_valid() {
not_valid = self.parse_keywords(&[Keyword::NOT, Keyword::VALID]);
}
AlterTableOperation::AddConstraint {
constraint,
not_valid,

View file

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