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

case search "date_add" function #31388

Merged
merged 12 commits into from
Apr 5, 2022
2 changes: 2 additions & 0 deletions corehq/apps/case_search/dsl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
def unwrap_value(domain, node):
"""Returns the value of the node if it is wrapped in a function, otherwise just returns the node
"""
if isinstance(node, (str, int, float, bool)):
return node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious what this achieves that the if not isinstance(node, FunctionCall) line doesn't catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. What I was wanting to do was only permit certain types here. For example it should not return a BinaryExpression. But on more reflection perhaps that doesn't belong here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isinstance(node, UnaryExpression) and node.op == '-':
return -1 * node.right
if not isinstance(node, FunctionCall):
Expand Down