You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dateutil.parser.isoparse is meant to be used to transfrom ISO 8601 datetime strings into datetime objects. However, it is being used in FakeQueryCondition to parse a datetime object, which is both redundant and erroneous.
I'm actually seeing the proble that doc_val stays a string for me in fake_elasticsearch:
for sign, value in comparisons.items():
if isinstance(doc_val, datetime.datetime):
value = dateutil.parser.isoparse(value)
if sign == 'gte':
> if doc_val < value:
E TypeError: '<' not supported between instances of 'str' and 'datetime.datetime'
In the mapping the field is defined as {"type": "date"} and value seems to already be a datetime.datetime, but doc_val is still a string
I see FakeIndicesClient ignores body, so types have to be converted by hand before adding.
In case anyone stumbles across this as well.
I patched dateutil.parser.isoparse to achieve what @JimGomez48 was talking about:
dateutil.parser.isoparse is meant to be used to transfrom ISO 8601 datetime strings into datetime objects. However, it is being used in FakeQueryCondition to parse a datetime object, which is both redundant and erroneous.
See https://github.com/vrcmarcos/elasticmock/blob/master/elasticmock/fake_elasticsearch.py#L179-L180
Proposal: Use a try/except block to try to parse the value. If exception on isoparse(), pass and continue.
The text was updated successfully, but these errors were encountered: