﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20971	Annotating a count of distinct ForeignKey (a) of a reverse foreignkey (b) doesn't work on oracle if (a) has any TextFields	kimvais@…	nobody	"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."	Bug	closed	Database layer (models, ORM)	1.5	Normal	duplicate	oracle		Accepted	0	0	0	0	0	0
