mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
Rename AlterOperation -> AlterTableOperation
Since other ALTER statements will have separate sub-commands.
This commit is contained in:
parent
aab0c36443
commit
8569a61fd0
4 changed files with 9 additions and 9 deletions
|
@ -4,18 +4,18 @@ use super::{ASTNode, SQLIdent, SQLObjectName};
|
|||
|
||||
/// An `ALTER TABLE` (`SQLStatement::SQLAlterTable`) operation
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum AlterOperation {
|
||||
pub enum AlterTableOperation {
|
||||
/// `ADD <table_constraint>`
|
||||
AddConstraint(TableConstraint),
|
||||
/// TODO: implement `DROP CONSTRAINT name`
|
||||
/// TODO: implement `DROP CONSTRAINT <name>`
|
||||
DropConstraint { name: SQLIdent },
|
||||
}
|
||||
|
||||
impl ToString for AlterOperation {
|
||||
impl ToString for AlterTableOperation {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
AlterOperation::AddConstraint(constraint) => format!("ADD {}", constraint.to_string()),
|
||||
AlterOperation::DropConstraint { name } => format!("DROP CONSTRAINT {}", name),
|
||||
AlterTableOperation::AddConstraint(c) => format!("ADD {}", c.to_string()),
|
||||
AlterTableOperation::DropConstraint { name } => format!("DROP CONSTRAINT {}", name),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ mod sql_operator;
|
|||
mod sqltype;
|
||||
mod value;
|
||||
|
||||
pub use self::ddl::{AlterOperation, TableConstraint};
|
||||
pub use self::ddl::{AlterTableOperation, TableConstraint};
|
||||
pub use self::query::{
|
||||
Cte, Fetch, Join, JoinConstraint, JoinOperator, SQLOrderByExpr, SQLQuery, SQLSelect,
|
||||
SQLSelectItem, SQLSetExpr, SQLSetOperator, TableFactor,
|
||||
|
@ -405,7 +405,7 @@ pub enum SQLStatement {
|
|||
SQLAlterTable {
|
||||
/// Table name
|
||||
name: SQLObjectName,
|
||||
operation: AlterOperation,
|
||||
operation: AlterTableOperation,
|
||||
},
|
||||
/// DROP TABLE
|
||||
SQLDrop {
|
||||
|
|
|
@ -974,7 +974,7 @@ impl Parser {
|
|||
let table_name = self.parse_object_name()?;
|
||||
let operation = if self.parse_keyword("ADD") {
|
||||
if let Some(constraint) = self.parse_optional_table_constraint()? {
|
||||
AlterOperation::AddConstraint(constraint)
|
||||
AlterTableOperation::AddConstraint(constraint)
|
||||
} else {
|
||||
return self.expected("a constraint in ALTER TABLE .. ADD", self.peek_token());
|
||||
}
|
||||
|
|
|
@ -758,7 +758,7 @@ fn parse_alter_table_constraints() {
|
|||
match verified_stmt(&format!("ALTER TABLE tab ADD {}", constraint_text)) {
|
||||
SQLStatement::SQLAlterTable {
|
||||
name,
|
||||
operation: AlterOperation::AddConstraint(constraint),
|
||||
operation: AlterTableOperation::AddConstraint(constraint),
|
||||
} => {
|
||||
assert_eq!("tab", name.to_string());
|
||||
assert_eq!(constraint_text, constraint.to_string());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue