Opened 4 years ago
Last modified 4 years ago
#32483 closed Bug
querying JSONField in sqlite returns ints for booleans — at Initial Version
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
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 'datavalue':
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'
Note:
See TracTickets
for help on using tickets.