Skip to main content

surrealdb_sql/record_id/
mod.rs

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