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