#13937: Sub-query (exclude) fails when joining
---------------------------------------------------+------------------------
Reporter: subsume | Owner:
Status: new | Milestone:
Component: Database layer (models, ORM) | Version: 1.2
Resolution: | Keywords:
Stage: Accepted | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------------+------------------------
Changes (by russellm):
* stage: Unreviewed => Accepted
Comment:
For posterity, the full set of models are:
{{{
class Consumer(models.Model):
race = models.CharField(max_length=100)
class Contact(models.Model):
consumer = models.ForeignKey(Consumer,null=True,blank=True)
date = models.DateField()
}}}
The IS NULL clause is being added because the foreign key is nullable, so
the query engine is making sure that you aren't joining on a Contact entry
that has a date in range, but has no related Consumer. However, it seems
to be picking the wrong table alias (using the base table, instead of U1).
--
Ticket URL: <http://code.djangoproject.com/ticket/13937#comment:5>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.