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

jmespath exclude_empty fix #372

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
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
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