Opened 11 years ago

Last modified 10 years ago

#20971 closed Bug

Annotating a count of distinct ForeignKey (a) of a reverse foreignkey (b) doesn't work on oracle if (a) has any TextFields — at Initial Version

Reported by: kimvais@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.5
Severity: Normal Keywords: oracle
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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('zpk', 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('zpk'))
Works flawlessly on PostgreSQL.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top