Skip to main content

surql_parser/upstream/sql/record_id/
range.rs

1use super::RecordIdKeyLit;
2use std::ops::Bound;
3use surrealdb_types::{SqlFormat, ToSql};
4#[derive(Clone, Debug, PartialEq, Eq)]
5pub struct RecordIdKeyRangeLit {
6	pub start: Bound<RecordIdKeyLit>,
7	pub end: Bound<RecordIdKeyLit>,
8}
9impl ToSql for RecordIdKeyRangeLit {
10	fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
11		match &self.start {
12			Bound::Unbounded => {}
13			Bound::Included(v) => v.fmt_sql(f, fmt),
14			Bound::Excluded(v) => {
15				v.fmt_sql(f, fmt);
16				f.push('>');
17			}
18		}
19		match &self.end {
20			Bound::Unbounded => f.push_str(".."),
21			Bound::Excluded(v) => {
22				f.push_str("..");
23				v.fmt_sql(f, fmt);
24			}
25			Bound::Included(v) => {
26				f.push_str("..=");
27				v.fmt_sql(f, fmt);
28			}
29		}
30	}
31}