grafbase_sql_ast/ast/function/
json_unquote.rs

1use super::Function;
2use crate::ast::{Expression, FunctionType};
3
4#[derive(Debug, Clone, PartialEq)]
5pub struct JsonUnquote<'a> {
6    pub(crate) expr: Box<Expression<'a>>,
7}
8
9/// Converts a JSON expression into string and unquotes it.
10pub fn json_unquote<'a, E>(expr: E) -> Function<'a>
11where
12    E: Into<Expression<'a>>,
13{
14    let fun = JsonUnquote {
15        expr: Box::new(expr.into()),
16    };
17
18    fun.into()
19}
20
21impl<'a> From<JsonUnquote<'a>> for Function<'a> {
22    fn from(value: JsonUnquote<'a>) -> Self {
23        Self {
24            typ_: FunctionType::JsonUnquote(value),
25            alias: None,
26        }
27    }
28}