Skip to main content

surrealdb_sql/statements/remove/
bucket.rs

1use surrealdb_types::{SqlFormat, ToSql, write_sql};
2
3use crate::{CoverStmts, Expr, Literal};
4
5#[derive(Clone, Debug, Eq, PartialEq)]
6#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
7pub struct RemoveBucketStatement {
8	pub name: Expr,
9	pub if_exists: bool,
10}
11
12impl Default for RemoveBucketStatement {
13	fn default() -> Self {
14		Self {
15			name: Expr::Literal(Literal::None),
16			if_exists: false,
17		}
18	}
19}
20
21impl ToSql for RemoveBucketStatement {
22	fn fmt_sql(&self, f: &mut String, sql_fmt: SqlFormat) {
23		write_sql!(f, sql_fmt, "REMOVE BUCKET");
24		if self.if_exists {
25			write_sql!(f, sql_fmt, " IF EXISTS");
26		}
27		write_sql!(f, sql_fmt, " {}", CoverStmts(&self.name));
28	}
29}