Skip to main content

JsonType

Trait JsonType 

Source
pub trait JsonType {
    type Field: DataType;
}
Expand description

SQL types the JSON access operators (->, ->>, #>, #>>) accept.

Implemented for json, jsonb, and untyped SQL (Any, treated as json). Text columns are rejected even when they hold JSON; cast them first.

§Type safety

ⓘ
use drizzle_core::expr::raw_non_null;
use drizzle_postgres::expr::json_get_text;
use drizzle_postgres::values::PostgresValue;
use drizzle_types::postgres::types::Text;

let raw = raw_non_null::<PostgresValue, Text>("raw");
let _ = json_get_text(raw, "name"); // `text` is not a JSON type

Required Associated Types§

Source

type Field: DataType

The SQL type -> and #> return: json for json, jsonb for jsonb, and json for untyped SQL.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§