1use inherent::inherent;
2
3use crate::{backend::SchemaBuilder, types::*, SchemaStatementBuilder, TableIndex};
4
5#[derive(Default, Debug, Clone)]
31pub struct IndexDropStatement {
32 pub(crate) table: Option<TableRef>,
33 pub(crate) index: TableIndex,
34 pub(crate) if_exists: bool,
35}
36
37impl IndexDropStatement {
38 pub fn new() -> Self {
40 Self::default()
41 }
42
43 pub fn name<T>(&mut self, name: T) -> &mut Self
45 where
46 T: Into<String>,
47 {
48 self.index.name(name);
49 self
50 }
51
52 pub fn table<T>(&mut self, table: T) -> &mut Self
54 where
55 T: IntoTableRef,
56 {
57 self.table = Some(table.into_table_ref());
58 self
59 }
60
61 pub fn if_exists(&mut self) -> &mut Self {
62 self.if_exists = true;
63 self
64 }
65}
66
67#[inherent]
68impl SchemaStatementBuilder for IndexDropStatement {
69 pub fn build<T: SchemaBuilder>(&self, schema_builder: T) -> String {
70 let mut sql = String::with_capacity(256);
71 schema_builder.prepare_index_drop_statement(self, &mut sql);
72 sql
73 }
74
75 pub fn build_any(&self, schema_builder: &dyn SchemaBuilder) -> String {
76 let mut sql = String::with_capacity(256);
77 schema_builder.prepare_index_drop_statement(self, &mut sql);
78 sql
79 }
80
81 pub fn to_string<T: SchemaBuilder>(&self, schema_builder: T) -> String;
82}