yezyilomo / django-restql

Turn your API made with Django REST Framework(DRF) into a GraphQL like API.
https://yezyilomo.github.io/django-restql
MIT License
620 stars 43 forks source link

Unable to filter by datetime #157

Closed Nizebulous closed 4 years ago

Nizebulous commented 4 years ago

When I try to specify a datetime as a filter, it breaks the restql parsing. Example query:

?query=(last_queried_on__lt:2020-04-27T23:02:32Z){{*}}

When I attempt that query, I get a 400:

QuerySyntaxError: expecting \'{\' on (last_queried_on__lt
yezyilomo commented 4 years ago

That's due to : in the date, Here is the line including : as a special char for separating argument name and its value. https://github.com/yezyilomo/django-restql/blob/8e14631906b2d67e5291ce6acdf5be26389a4470/django_restql/parser.py#L19-L22 We have to find a way to escape those with something like quotes e.g "2020-04-27T23:02:32Z" or '2020-04-27T23:02:32Z'.

Nizebulous commented 4 years ago

Yes. This was what I was hoping for. I think it would be useful in other places as well.