Function quaint::ast::row_to_json

source ·
pub fn row_to_json<'a, T>(expr: T, pretty_print: bool) -> Function<'a>where
    T: Into<Table<'a>>,
Available on crate feature postgresql only.
Expand description

Return the given table in JSON format.

Only available for Postgresql

let cte = Select::default()
    .value(val!("hello_world").alias("toto"))
    .into_cte("one");

let select = Select::from_table("one")
    .value(row_to_json("one", false))
    .with(cte);

let result = conn.select(select).await?;

assert_eq!(
    Value::Json(Some(serde_json::json!({
        "toto": "hello_world"
    }))),
    result.into_single().unwrap()[0]
);