Skip to main content

surrealdb_sql/
fetch.rs

1use std::ops::Deref;
2
3use common::fmt::Fmt;
4use surrealdb_types::{SqlFormat, ToSql, write_sql};
5
6use crate::Expr;
7
8#[derive(Clone, Debug, Default, Eq, PartialEq)]
9#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
10pub struct Fetchs(
11	#[cfg_attr(feature = "arbitrary", arbitrary(with = crate::arbitrary::atleast_one))]
12	pub  Vec<Fetch>,
13);
14
15impl Deref for Fetchs {
16	type Target = Vec<Fetch>;
17	fn deref(&self) -> &Self::Target {
18		&self.0
19	}
20}
21
22impl ToSql for Fetchs {
23	fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
24		write_sql!(f, fmt, "FETCH {}", Fmt::comma_separated(&self.0))
25	}
26}
27
28#[derive(Clone, Debug, Eq, PartialEq)]
29pub struct Fetch(pub Expr);
30
31impl ToSql for Fetch {
32	fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
33		self.0.fmt_sql(f, fmt);
34	}
35}