#31973: TypeError loading data in JSONField if DB has native JSON support
-------------------------------------+-------------------------------------
     Reporter:  Adam Alton           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by giacomo):

 Replying to [comment:20 Mariusz Felisiak]:
 > Do you really want to get `JSON` as a result of `JSONB_ARRAY_LENGTH()`?
 I think you missed `output_field`, e.g.
 > {{{
 > MyModel.objects.annotate(field_len=Func(F('field'),
 function='jsonb_array_length', output_field=IntegerField()))
 > }}}
 > works fine.

 Thanks, I missed that part of the `Func` documentation and I was also
 confused because it stopped working in a minor version. The documentation
 could be improved, though: `output_field` is not included in the class
 attributes and is only mentioned at the end without an example...

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31973#comment:21>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.c086b6048133521a54d25cae92d19068%40djangoproject.com.

Reply via email to