Skip to main content

surrealdb_expr/expr/
base.rs

1use std::fmt;
2
3use surrealdb_types::{SqlFormat, ToSql};
4
5#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash)]
6pub enum Base {
7	#[default]
8	Root,
9	Ns,
10	Db,
11}
12
13impl fmt::Display for Base {
14	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15		match self {
16			Self::Ns => f.write_str("NAMESPACE"),
17			Self::Db => f.write_str("DATABASE"),
18			Self::Root => f.write_str("ROOT"),
19		}
20	}
21}
22
23impl ToSql for Base {
24	fn fmt_sql(&self, f: &mut String, sql_fmt: SqlFormat) {
25		let sql_base: crate::sql::Base = (*self).into();
26		sql_base.fmt_sql(f, sql_fmt);
27	}
28}