surrealdb_sql/statements/define/config/
defaults.rs1use surrealdb_types::{SqlFormat, ToSql, write_sql};
2
3use crate::{Expr, Literal};
4
5#[derive(Clone, Debug, Eq, PartialEq)]
6#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
7pub struct DefaultConfig {
8 pub namespace: Expr,
9 pub database: Expr,
10}
11
12impl Default for DefaultConfig {
13 fn default() -> Self {
14 Self {
15 namespace: Expr::Literal(Literal::None),
16 database: Expr::Literal(Literal::None),
17 }
18 }
19}
20
21impl ToSql for DefaultConfig {
22 fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
23 write_sql!(f, fmt, " DEFAULT");
24 write_sql!(f, fmt, " NAMESPACE {}", self.namespace);
25 write_sql!(f, fmt, " DATABASE {}", self.database);
26 }
27}