surql_parser/upstream/sql/statements/remove/
event.rs1use crate::upstream::fmt::CoverStmts;
2use crate::upstream::sql::{Expr, Literal};
3use surrealdb_types::{SqlFormat, ToSql, write_sql};
4#[derive(Clone, Debug, Eq, PartialEq)]
5#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
6pub struct RemoveEventStatement {
7 pub name: Expr,
8 pub what: Expr,
9 pub if_exists: bool,
10}
11impl Default for RemoveEventStatement {
12 fn default() -> Self {
13 Self {
14 name: Expr::Literal(Literal::None),
15 what: Expr::Literal(Literal::None),
16 if_exists: false,
17 }
18 }
19}
20impl ToSql for RemoveEventStatement {
21 fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
22 write_sql!(f, fmt, "REMOVE EVENT");
23 if self.if_exists {
24 write_sql!(f, fmt, " IF EXISTS");
25 }
26 write_sql!(
27 f,
28 fmt,
29 " {} ON {}",
30 CoverStmts(&self.name),
31 CoverStmts(&self.what)
32 );
33 }
34}