Re: SQL join promotion as a result of querying for a NULL value

2011-01-06 Thread Byron Ruth
> Just to be clear: The assumption is that if: >         1) the user filtered on a related model's field >         2) with is_null=True, and >         3) there is a nullable FK in the chain leading to the filtered field >            (this is checked by promote_alias_chain), > then: > use a left out

Re: SQL join promotion as a result of querying for a NULL value

2011-01-06 Thread Shai Berger
On Thursday 06 January 2011, Byron Ruth wrote: > I am speaking of this particular if statement: > http://code.djangoproject.com/browser/django/tags/releases/1.2.4/django/db/ > models/sql/query.py#L1051 > > There are a few implications of this assumption. Just to be clear: The assumption is that i

Re: SQL join promotion as a result of querying for a NULL value

2011-01-06 Thread Philippe Raoult
I too was rather surprised by this behavior. I have since changed my code to use exclude(related__field__isnull = False) instead of filter(related__field__isnull = True) to avoid this issue. I'm all for an API, but I'm not sure which would be best. Maybe filter(related__field__isnull_nopromote = T

SQL join promotion as a result of querying for a NULL value

2011-01-06 Thread Byron Ruth
I am speaking of this particular if statement: http://code.djangoproject.com/browser/django/tags/releases/1.2.4/django/db/models/sql/query.py#L1051 There are a few implications of this assumption. One being, that if the user is actually trying to get the "real" rows that exist with a column that h