Skip to main content

Module expr

Module expr 

Source
Expand description

SQLite JSON functions and conditions.

These helpers build untyped SQL fragments for JSON stored in TEXT or BLOB columns. JSON paths, keys and values are sent as bound parameters. For standard, typed expressions use drizzle_core::expr.

Functions§

json
Wraps value in json(..), which checks that it is valid JSON and returns it as minified JSON text.
json_array_contains
Builds an EXISTS test that is true when the JSON array at path has an element equal to value.
json_contains
Builds json_extract(left, path) = value: the value at path equals value.
json_eq
Builds left ->> field = value: the JSON field field equals value.
json_exists
Builds json_type(left, path) IS NOT NULL: the JSON document has a value at path (a JSON null counts as present).
json_extract
Builds left ->> path, which returns the value at path as an SQL value (TEXT, INTEGER, REAL or NULL).
json_extract_text
Builds left -> path, which returns the value at path as JSON text (strings stay quoted, objects and arrays stay JSON).
json_gt
Builds CAST(json_extract(left, path) AS NUMERIC) > value: the number at path is greater than value.
json_ne
Builds left ->> field != value: the JSON field field does not equal value.
json_not_exists
Builds json_type(left, path) IS NULL: the JSON document has no value at path.
json_object_contains_key
Builds a test that is true when the JSON object at path has the key key.
json_text_contains
Builds a case-insensitive substring test: the text at path contains value.
jsonb
Wraps value in jsonb(..), which checks that it is valid JSON and returns it in SQLite’s binary JSONB format.