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
valueinjson(..), which checks that it is valid JSON and returns it as minified JSON text. - json_
array_ contains - Builds an
EXISTStest that is true when the JSON array atpathhas an element equal tovalue. - json_
contains - Builds
json_extract(left, path) = value: the value atpathequalsvalue. - json_eq
- Builds
left ->> field = value: the JSON fieldfieldequalsvalue. - json_
exists - Builds
json_type(left, path) IS NOT NULL: the JSON document has a value atpath(a JSONnullcounts as present). - json_
extract - Builds
left ->> path, which returns the value atpathas an SQL value (TEXT, INTEGER, REAL or NULL). - json_
extract_ text - Builds
left -> path, which returns the value atpathas JSON text (strings stay quoted, objects and arrays stay JSON). - json_gt
- Builds
CAST(json_extract(left, path) AS NUMERIC) > value: the number atpathis greater thanvalue. - json_ne
- Builds
left ->> field != value: the JSON fieldfielddoes not equalvalue. - json_
not_ exists - Builds
json_type(left, path) IS NULL: the JSON document has no value atpath. - json_
object_ contains_ key - Builds a test that is true when the JSON object at
pathhas the keykey. - json_
text_ contains - Builds a case-insensitive substring test: the text at
pathcontainsvalue. - jsonb
- Wraps
valueinjsonb(..), which checks that it is valid JSON and returns it inSQLite’s binary JSONB format.