Restore is empty functions as before (#1657)

* is_empty should match with value=null

* fmt
This commit is contained in:
Andrey Vasnetsov
2023-04-04 12:17:07 +02:00
parent de93c75bf3
commit e43e24deb2
2 changed files with 14 additions and 4 deletions

View File

@@ -72,15 +72,24 @@ impl MultiValue<&Value> {
Self::Single(val) => match val {
None => true,
Some(Value::Array(vec)) => vec.is_empty(),
Some(Value::Null) => true,
_ => false,
},
}
}
pub(crate) fn check_is_null(&self) -> bool {
if let Self::Single(Some(val)) = self {
return val.is_null();
match self {
MultiValue::Single(val) => {
if let Some(val) = val {
return val.is_null();
}
false
}
// { "a": [ { "b": null }, { "b": 1 } ] } => true
// { "a": [ { "b": 1 }, { "b": null } ] } => true
// { "a": [ { "b": 1 }, { "b": 2 } ] } => false
MultiValue::Multiple(vals) => vals.iter().any(|val| val.is_null()),
}
false
}
}

View File

@@ -150,11 +150,12 @@ def is_empty_condition():
assert response.ok
json = response.json()
assert len(json['result']) == 3
assert len(json['result']) == 4
ids = [x['id'] for x in json['result']]
assert 5 in ids
assert 6 in ids
assert 7 in ids
assert 8 in ids