Skip to main content

json_contains

Function json_contains 

Source
pub fn json_contains<'a, L, R>(
    left: L,
    path: &'a str,
    value: R,
) -> SQL<'a, SQLiteValue<'a>>
where L: ToSQL<'a, SQLiteValue<'a>>, R: Into<SQLiteValue<'a>>,
Expand description

Builds json_extract(left, path) = value: the value at path equals value.

Despite the name, this is an equality test, not a substring or array-membership test. Use json_array_contains or json_text_contains for those.

ยงExamples

let column = SQL::<SQLiteValue>::raw("metadata");
let condition = json_contains(column, "$.preferences[0]", "dark_theme");
assert_eq!(condition.sql(), "json_extract( metadata , ? ) = ?");