sea_query/table/
truncate.rs1use crate::{SchemaStatementBuilder, backend::SchemaBuilder, types::*};
2
3#[derive(Default, Debug, Clone)]
23pub struct TableTruncateStatement {
24 pub(crate) table: Option<TableRef>,
25}
26
27impl TableTruncateStatement {
28 pub fn new() -> Self {
30 Self::default()
31 }
32
33 pub fn table<T>(&mut self, table: T) -> &mut Self
35 where
36 T: IntoTableRef,
37 {
38 self.table = Some(table.into_table_ref());
39 self
40 }
41
42 pub fn take(&mut self) -> Self {
43 Self {
44 table: self.table.take(),
45 }
46 }
47}
48
49impl SchemaStatementBuilder for TableTruncateStatement {
50 fn build<T: SchemaBuilder>(&self, schema_builder: T) -> String {
51 let mut sql = String::with_capacity(256);
52 schema_builder.prepare_table_truncate_statement(self, &mut sql);
53 sql
54 }
55}
56
57impl TableTruncateStatement {
58 pub fn build<T: SchemaBuilder>(&self, schema_builder: T) -> String {
59 <Self as SchemaStatementBuilder>::build(self, schema_builder)
60 }
61
62 pub fn to_string<T: SchemaBuilder>(&self, schema_builder: T) -> String {
63 <Self as SchemaStatementBuilder>::to_string(self, schema_builder)
64 }
65}