pub fn json_get_text<'a, E>(
expr: E,
key: &'a str,
) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, E::Aggregate, E::Sources>Expand description
Gets an object field by key as text (->>).
The operand must be json or jsonb (JsonType). The result is NULL
when the key is missing or the value is JSON null.
ยงExamples
use drizzle_postgres::expr::json_get_text;
use drizzle_core::{ToSQL, expr::raw_non_null};
use drizzle_postgres::values::PostgresValue;
use drizzle_types::postgres::types::Jsonb;
let data = raw_non_null::<PostgresValue, Jsonb>("data");
let name = json_get_text(data, "name"); // a `text` expression
assert_eq!(name.to_sql().sql(), "data ->> CAST ($1 AS TEXT)");