sea_query/table/
truncate.rs1use inherent::inherent;
2
3use crate::{SchemaStatementBuilder, backend::SchemaBuilder, types::*};
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>(&self, schema_builder: T) -> String
54 where
55 T: SchemaBuilder,
56 {
57 let mut sql = String::with_capacity(256);
58 schema_builder.prepare_table_truncate_statement(self, &mut sql);
59 sql
60 }
61
62 pub fn to_string<T>(&self, schema_builder: T) -> String
63 where
64 T: SchemaBuilder;
65}