1use crate::idiom::Idiom;
2
3#[derive(Clone, Debug, Default, PartialEq, Eq)]
4pub struct Groups(pub Vec<Group>);
5
6impl surrealdb_types::ToSql for Groups {
7 fn fmt_sql(&self, f: &mut String, fmt: surrealdb_types::SqlFormat) {
8 if self.0.is_empty() {
9 f.push_str("GROUP ALL");
10 } else {
11 f.push_str("GROUP BY ");
12 for (i, item) in self.0.iter().enumerate() {
13 if i > 0 {
14 fmt.write_separator(f);
15 }
16 item.fmt_sql(f, fmt);
17 }
18 }
19 }
20}
21
22#[derive(Clone, Debug, Default, PartialEq, Eq)]
23#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
24pub struct Group(
25 #[cfg_attr(feature = "arbitrary", arbitrary(with = crate::arbitrary::basic_idiom))] pub Idiom,
26);
27
28impl surrealdb_types::ToSql for Group {
29 fn fmt_sql(&self, f: &mut String, fmt: surrealdb_types::SqlFormat) {
30 self.0.fmt_sql(f, fmt);
31 }
32}