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 @@ -1036,7 +1036,7 @@ pub trait Dialect: Debug + Any {
10361036 /// Returns true if the dialect supports `ADD <table_constraint> [NOT VALID]` in `ALTER TABLE` statements.
10371037 ///
10381038 /// -[PostgreSQL](https://www.postgresql.org/docs/17/sql-altertable.html)
1039- fn supports_constraint_not_validation ( & self ) -> bool {
1039+ fn supports_constraint_not_valid ( & self ) -> bool {
10401040 false
10411041 }
10421042
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 @@ -6236,7 +6236,7 @@ fn parse_ts_datatypes() {
62366236
62376237#[ test]
62386238fn parse_alter_table_constraint_not_valid ( ) {
6239- match pg_and_generic ( ) . verified_stmt (
6239+ match pg ( ) . verified_stmt (
62406240 "ALTER TABLE foo ADD CONSTRAINT bar FOREIGN KEY (baz) REFERENCES other(ref) NOT VALID" ,
62416241 ) {
62426242 Statement :: AlterTable { operations, .. } => {
You can’t perform that action at this time.
0 commit comments