Skip to main content

surql_parser/upstream/sql/
fetch.rs

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