Rename AlterOperation -> AlterTableOperation

Since other ALTER statements will have separate sub-commands.
This commit is contained in:
Nickolay Ponomarev 2019-05-08 04:01:10 +03:00
parent aab0c36443
commit 8569a61fd0
4 changed files with 9 additions and 9 deletions

View file

@ -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),
}
}
}

View file

@ -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 {

View file

@ -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());
}

View file

@ -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());