1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use super::Function;
use crate::ast::Table;

#[derive(Debug, Clone, PartialEq)]
/// A representation of the `to_jsonb` function in PostgreSQL.
pub struct ToJsonb<'a> {
    pub(crate) table: Table<'a>,
}

/// Return the given table in JSONB.
pub fn to_jsonb<'a>(table: impl Into<Table<'a>>) -> Function<'a> {
    let fun = ToJsonb {
        table: table.into(),
    };

    fun.into()
}

impl<'a> From<ToJsonb<'a>> for Function<'a> {
    fn from(value: ToJsonb<'a>) -> Self {
        Self {
            typ_: super::FunctionType::ToJsonb(value),
            alias: None,
        }
    }
}