#32483: querying JSONField in sqlite returns ints for booleans
-------------------------------------+-------------------------------------
     Reporter:  matthewcornell       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  jsonfield querying   |             Triage Stage:  Accepted
  sqlite                             |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by matthewcornell:

Old 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 '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'

New 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 {{{'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#comment:2>
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/072.1bafbb7eeccc8648e2ed6faa82d1d2ba%40djangoproject.com.

Reply via email to