File tree Expand file tree Collapse file tree 4 files changed +7
-4
lines changed
Expand file tree Collapse file tree 4 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -1064,7 +1064,7 @@ pub trait Dialect: Debug + Any {
10641064 /// Returns true if the dialect supports `ADD <table_constraint> [NOT VALID]` in `ALTER TABLE` statements.
10651065 ///
10661066 /// -[PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
1067- fn supports_constraint_not_validation ( & self ) -> bool {
1067+ fn supports_constraint_not_valid ( & self ) -> bool {
10681068 false
10691069 }
10701070
Original file line number Diff line number Diff line change @@ -259,7 +259,7 @@ impl Dialect for PostgreSqlDialect {
259259 true
260260 }
261261
262- fn supports_constraint_not_validation ( & self ) -> bool {
262+ fn supports_constraint_not_valid ( & self ) -> bool {
263263 true
264264 }
265265
Original file line number Diff line number Diff line change @@ -8477,7 +8477,10 @@ 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 not_valid = self.parse_keywords(&[Keyword::NOT, Keyword::VALID]);
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+ }
84818484 AlterTableOperation::AddConstraint {
84828485 constraint,
84838486 not_valid,
Original file line number Diff line number Diff line change @@ -6235,7 +6235,7 @@ fn parse_ts_datatypes() {
62356235
62366236#[ test]
62376237fn parse_alter_table_constraint_not_valid ( ) {
6238- match pg_and_generic ( ) . verified_stmt (
6238+ match pg ( ) . verified_stmt (
62396239 "ALTER TABLE foo ADD CONSTRAINT bar FOREIGN KEY (baz) REFERENCES other(ref) NOT VALID" ,
62406240 ) {
62416241 Statement :: AlterTable { operations, .. } => {
You can’t perform that action at this time.
0 commit comments