diff --git a/lib/segment/src/common/utils.rs b/lib/segment/src/common/utils.rs index 9aa07ffd61..56beb99e61 100644 --- a/lib/segment/src/common/utils.rs +++ b/lib/segment/src/common/utils.rs @@ -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 } } diff --git a/openapi/tests/openapi_integration/test_basic_retrieve_api.py b/openapi/tests/openapi_integration/test_basic_retrieve_api.py index 8a0f238a3f..e084935a51 100644 --- a/openapi/tests/openapi_integration/test_basic_retrieve_api.py +++ b/openapi/tests/openapi_integration/test_basic_retrieve_api.py @@ -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