#32483: querying JSONField in sqlite returns ints for booleans
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
matthewcornell |
Type: Bug | Status: new
Component: Database | Version: 3.1
layer (models, ORM) | Keywords: jsonfield querying
Severity: Normal | sqlite
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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'
--
Ticket URL: <https://code.djangoproject.com/ticket/32483>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/057.d3a0fafc71f5fb0da1f8ff5964bf5135%40djangoproject.com.