grafbase_sql_ast/ast/function/
row_to_json.rs1use super::Function;
2use crate::ast::{FunctionType, Table};
3
4#[derive(Debug, Clone, PartialEq)]
5#[cfg(feature = "postgresql")]
6pub struct RowToJson<'a> {
9 pub(crate) expr: Table<'a>,
10 pub(crate) pretty_print: bool,
11}
12
13#[cfg(feature = "postgresql")]
15pub fn row_to_json<'a, T>(expr: T, pretty_print: bool) -> Function<'a>
16where
17 T: Into<Table<'a>>,
18{
19 let fun = RowToJson {
20 expr: expr.into(),
21 pretty_print,
22 };
23
24 fun.into()
25}
26
27impl<'a> From<RowToJson<'a>> for Function<'a> {
28 fn from(value: RowToJson<'a>) -> Self {
29 Self {
30 typ_: FunctionType::RowToJson(value),
31 alias: None,
32 }
33 }
34}