#20971: Annotating a count of distinct ForeignKey (a) of a reverse foreignkey 
(b)
doesn't work on oracle if (a) has any TextFields
----------------------------------------------+--------------------
     Reporter:  kimvais@…                     |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.5
     Severity:  Normal                        |   Keywords:  oracle
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 If there is a model X that has foreignkey to model Y and X has foreign key
 to Z and has TextFields the query for an instance of Y fails.

 E.g.
 y.xys.all().defer(list_of_all_text_fields).annotate(Count('z__pk',
 distinct=True) causes "DatabaseError: ORA-00932: inconsistent datatypes:
 expected - got NCLOB"

 This is probably(?) because the "GROUP BY" clause will contain all the
 deferred fields.

 As a workaround I have to do sum(len(set(x)) for x in
 y.xys.all().values_list('z__pk'))
 Works flawlessly on PostgreSQL.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20971>
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/058.ebcfbbea18b31917484e8bf2d655c521%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to