surrealdb_expr/expr/
block.rs1use std::ops::Deref;
2
3use surrealdb_types::ToSql;
4
5use crate::expr::statements::info::InfoStructure;
6use crate::expr::{Expr, Value};
7
8#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
9pub struct Block(pub Vec<Expr>);
10
11impl Deref for Block {
12 type Target = [Expr];
13 fn deref(&self) -> &Self::Target {
14 &self.0
15 }
16}
17
18impl Block {
19 pub fn read_only(&self) -> bool {
21 self.0.iter().all(|x| x.read_only())
22 }
23}
24
25impl ToSql for Block {
26 fn fmt_sql(&self, f: &mut String, fmt: surrealdb_types::SqlFormat) {
27 let block: crate::sql::Block = self.clone().into();
28 block.fmt_sql(f, fmt);
29 }
30}
31
32impl InfoStructure for Block {
33 fn structure(self) -> Value {
34 Value::String(self.to_sql().into())
35 }
36}