#29769: Allow querying JSONField with F objects
------------------------------------+------------------------------------
     Reporter:  Gabor Körber        |                    Owner:  Mani
         Type:  New feature         |                   Status:  assigned
    Component:  contrib.postgres    |                  Version:
     Severity:  Normal              |               Resolution:
     Keywords:  F JSONField lookup  |             Triage Stage:  Accepted
    Has patch:  0                   |      Needs documentation:  0
  Needs tests:  0                   |  Patch needs improvement:  0
Easy pickings:  0                   |                    UI/UX:  0
------------------------------------+------------------------------------

Comment (by Uxio0):

 @GwynBleidD I see it as an issue that `F()` object is different from the
 regular field issue:

 `str(MyEvent.objects.values('arguments__to').query)`
 `'SELECT ("myapp_myevent"."arguments" -> \'to\') FROM "myapp_myevent"'`

 If I use `F()` object:

 `str(MyEvent.objects.values(x=F('arguments__to')).query)`
 `'SELECT "myapp_myevent"."arguments" AS "x" FROM "myapp_myevent"'`

 This way I'm not able to do casting on that field, for example:

 `str(MyEvent.objects.values(x=Cast(F('arguments__to'),
 DecimalField())).query)`
 `'SELECT ("myapp_myevent"."arguments")::numeric(None, None) AS "x" FROM
 "myapp_myevent"'`

 So for example I cannot find a way to translate this simple query:

 `SELECT SUM((arguments -> 'to')::decimal) as my_sum FROM myapp_myevent;`

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29769#comment:8>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.d901e84075b2fdb0731df694820e13c4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to