Opened 4 years ago
Last modified 4 years ago
#32483 closed Bug
querying JSONField in sqlite returns ints for booleans — at Version 2
Reported by: | Matthew Cornell | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.1 |
Severity: | Normal | Keywords: | jsonfield querying sqlite |
Cc: | sage | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I have a model with a JSONField:
class PredictionData(models.Model): data = models.JSONField()
One of the rows contains this dict: {'value': True
}.
I'm querying the model's JSON using 'data__value'
:
PredictionData.objects.values_list('data', 'data__value')
I get correct results for postgres (a boolean) but incorrect for sqlite3 (an int). For this query, sqlite3 wrongly returns:
({'value': True}, 1)
whereas postgres correctly returns
({'value': True}, True)
Same behavior with False/0.
versions:
Python 3.9.1
sqlite3.sqlite_version # '3.33.0'
django.version # '3.1.7'
Change History (2)
comment:1 by , 4 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 4 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.
I was able to reproduce the issue: