Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore is empty functions as before #1657

Merged
merged 2 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
is_empty should match with value=null
  • Loading branch information
generall committed Apr 4, 2023
commit 9ffb638841b5ca4918805835d0404c7ad7d6a343
17 changes: 14 additions & 3 deletions lib/segment/src/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,26 @@ 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
}
}

Expand Down
3 changes: 2 additions & 1 deletion openapi/tests/openapi_integration/test_basic_retrieve_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down