Enable searching within Record IDs using the CONTAINS operator

Closes #1377
This commit is contained in:
Tobie Morgan Hitchcock 2022-10-17 23:05:35 +01:00
parent 8902fc0a70
commit 73bf56810e

View file

@ -1044,6 +1044,10 @@ impl Value {
pub fn contains(&self, other: &Value) -> bool {
match self {
Value::Array(v) => v.iter().any(|v| v.equal(other)),
Value::Thing(v) => match other {
Value::Strand(w) => v.to_string().contains(w.as_str()),
_ => v.to_string().contains(&other.to_string().as_str()),
},
Value::Strand(v) => match other {
Value::Strand(w) => v.contains(w.as_str()),
_ => v.contains(&other.to_string().as_str()),