Skip to main content

json_text_contains

Function json_text_contains 

Source
pub fn json_text_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 a case-insensitive substring test: the text at path contains value.

Uses instr(lower(..), lower(..)) > 0, so case folding only applies to ASCII letters.

ยงExamples

let column = SQL::<SQLiteValue>::raw("metadata");
let condition = json_text_contains(column, "$.description", "user");
assert_eq!(
    condition.sql(),
    "instr(lower(json_extract( metadata , ? )), lower( ? )) > 0"
);