Skip to main content

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