mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
only use in postgres
This commit is contained in:
parent
0e174c2b05
commit
b3da639810
4 changed files with 7 additions and 4 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ impl Dialect for PostgreSqlDialect {
|
|||
true
|
||||
}
|
||||
|
||||
fn supports_constraint_not_validation(&self) -> bool {
|
||||
fn supports_constraint_not_valid(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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, .. } => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue