Skip to main content

surql_parser/upstream/sql/record_id/
mod.rs

1use crate::compat::val::TableName;
2use crate::upstream::fmt::EscapeIdent;
3use surrealdb_types::{SqlFormat, ToSql, write_sql};
4pub mod key;
5pub use key::{RecordIdKeyGen, RecordIdKeyLit};
6pub mod range;
7pub use range::RecordIdKeyRangeLit;
8/// A record id literal, needs to be evaluated to get the actual record id.
9#[derive(Clone, Debug, Eq, PartialEq)]
10#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
11pub struct RecordIdLit {
12	/// Table name
13	pub table: String,
14	pub key: RecordIdKeyLit,
15}
16impl ToSql for RecordIdLit {
17	fn fmt_sql(&self, f: &mut String, sql_fmt: SqlFormat) {
18		write_sql!(f, sql_fmt, "{}:{}", EscapeIdent(&self.table), self.key);
19	}
20}