use crate::{backend::SchemaBuilder, types::*, SchemaStatementBuilder, TableIndex};
#[derive(Debug, Clone)]
pub struct IndexDropStatement {
pub(crate) table: Option<TableRef>,
pub(crate) index: TableIndex,
}
impl Default for IndexDropStatement {
fn default() -> Self {
Self::new()
}
}
impl IndexDropStatement {
pub fn new() -> Self {
Self {
table: None,
index: Default::default(),
}
}
pub fn name(&mut self, name: &str) -> &mut Self {
self.index.name(name);
self
}
pub fn table<T>(&mut self, table: T) -> &mut Self
where
T: IntoTableRef,
{
self.table = Some(table.into_table_ref());
self
}
}
impl SchemaStatementBuilder for IndexDropStatement {
fn build<T: SchemaBuilder>(&self, schema_builder: T) -> String {
let mut sql = String::with_capacity(256);
schema_builder.prepare_index_drop_statement(self, &mut sql);
sql
}
fn build_any(&self, schema_builder: &dyn SchemaBuilder) -> String {
let mut sql = String::with_capacity(256);
schema_builder.prepare_index_drop_statement(self, &mut sql);
sql
}
}