pub fn json_get_path_text<'a, E>(
expr: E,
path: &'a str,
) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, E::Aggregate, E::Sources>Expand description
Gets the value at a path as text (#>>).
path is a PostgreSQL text-array literal such as "{address,city}".
The operand must be json or jsonb (JsonType). The result is NULL
when the path does not exist.
ยงExamples
use drizzle_postgres::expr::json_get_path_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 city = json_get_path_text(data, "{address,city}");
assert_eq!(city.to_sql().sql(), "data #>> CAST ($1 AS TEXT[])");