surrealdb_expr/expr/record_id/
mod.rs1use common::fmt::EscapeIdent;
2use surrealdb_types::{SqlFormat, ToSql, write_sql};
3
4use crate::val::TableName;
5
6pub mod key;
7pub use key::{RecordIdKeyGen, RecordIdKeyLit};
8pub mod range;
9pub use range::RecordIdKeyRangeLit;
10
11#[derive(Clone, Debug, Eq, PartialEq, Hash)]
12pub struct RecordIdLit {
13 pub table: TableName,
15 pub key: RecordIdKeyLit,
16}
17
18impl RecordIdLit {
19 pub fn is_static(&self) -> bool {
20 self.key.is_static()
21 }
22
23 pub fn read_only(&self) -> bool {
26 self.key.read_only()
27 }
28}
29
30impl ToSql for RecordIdLit {
31 fn fmt_sql(&self, f: &mut String, sql_fmt: SqlFormat) {
32 write_sql!(f, sql_fmt, "{}:{}", EscapeIdent(&self.table), self.key)
33 }
34}