Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#27134 closed Bug (invalid)

JSONField key values are not escaped correctly in queries

Reported by: onur mat Owned by: nobody
Component: contrib.postgres Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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)

comment:1 by onur mat, 8 years ago

Component: Uncategorizedcontrib.postgres
Type: UncategorizedBug

comment:2 by onur mat, 8 years ago

Resolution: fixed
Status: newclosed

comment:3 by onur mat, 8 years ago

My bad. It was a typo. It is working as expected. Sorry.

comment:4 by Tim Graham, 8 years ago

Resolution: fixedinvalid
Note: See TracTickets for help on using tickets.
Back to Top