surrealdb_sql/statements/remove/
database.rs1use 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 RemoveDatabaseStatement {
8 pub name: Expr,
9 pub if_exists: bool,
10 pub expunge: bool,
11}
12
13impl Default for RemoveDatabaseStatement {
14 fn default() -> Self {
15 Self {
16 name: Expr::Literal(Literal::None),
17 if_exists: false,
18 expunge: false,
19 }
20 }
21}
22
23impl ToSql for RemoveDatabaseStatement {
24 fn fmt_sql(&self, f: &mut String, sql_fmt: SqlFormat) {
25 write_sql!(f, sql_fmt, "REMOVE DATABASE");
26 if self.expunge {
27 write_sql!(f, sql_fmt, " AND EXPUNGE");
28 }
29 if self.if_exists {
30 write_sql!(f, sql_fmt, " IF EXISTS");
31 }
32 write_sql!(f, sql_fmt, " {}", CoverStmts(&self.name));
33 }
34}