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