Skip to content

Commit

Permalink
Merge pull request #372 from biothings/exclude-empty-fix
Browse files Browse the repository at this point in the history
jmespath exclude_empty fix
  • Loading branch information
newgene authored Jan 2, 2025
2 parents fdfe588 + 387c7c2 commit a2201a2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion biothings/web/query/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def trasform_jmespath(self, path: str, obj, doc, options) -> None:
# each item in the obj list has already been transformed during the traversal
# in the else block below, so we only need to handle the list itself here
if jmespath_exclude_empty:
idx_to_remove = [i for i, _obj in enumerate(obj) if not _obj[target_field]]
idx_to_remove = [i for i, _obj in enumerate(obj) if not _obj.get(target_field)]
list_trim(obj, idx_to_remove) # remove item in-place from obj
# if obj is empty, mark the hit to be removed from the hits list
# otherwise, we make sure the hit does not have the __exclude__ mark
Expand Down

0 comments on commit a2201a2

Please sign in to comment.