surrealdb_sql/statements/alter/
sequence.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 AlterSequenceStatement {
8 pub name: Expr,
9 pub if_exists: bool,
10 pub timeout: Option<Expr>,
11}
12
13impl Default for AlterSequenceStatement {
14 fn default() -> Self {
15 Self {
16 name: Expr::Literal(Literal::None),
17 if_exists: false,
18 timeout: None,
19 }
20 }
21}
22
23impl ToSql for AlterSequenceStatement {
24 fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
25 write_sql!(f, fmt, "ALTER SEQUENCE");
26 if self.if_exists {
27 write_sql!(f, fmt, " IF EXISTS");
28 }
29 write_sql!(f, fmt, " {}", CoverStmts(&self.name));
30 if let Some(timeout) = &self.timeout {
31 write_sql!(f, fmt, " TIMEOUT {}", CoverStmts(timeout));
32 }
33 }
34}