JSONField key values are not escaped correctly in queries
If a dictionary stored in a JSONField has a key that contains '/', like a URI, it is not possible to use that value as a query parameter.
class Token(models.Model):
status = JSONField()
>>> Token.objects.create(status={
... '/help/tos': {'remaining': 10},
... })
>>> kwargs = {'status__/help/tos__remaining__gt': 0,}
>>> Token.objects.filter(**kwargs)
<QuerySet []>
Change History
(4)
| Component: |
Uncategorized → contrib.postgres
|
| Type: |
Uncategorized → Bug
|
| Resolution: |
→ fixed
|
| Status: |
new → closed
|
| Resolution: |
fixed → invalid
|
My bad. It was a typo. It is working as expected. Sorry.