#25972 closed Bug (fixed)
Filtering a ForeignObject with 'isnull' lookup fails in Django 1.9
| Reported by: | Tomo Otsuka | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.9 |
| Severity: | Release blocker | Keywords: | ForeignObject |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Introduced by this PR: https://github.com/django/django/pull/4036
For example, with the following models:
from django.db import models
class Author(models.Model):
id = models.IntegerField()
name = models.CharField()
class Meta:
app_label = 'foo'
class Book(models.Model):
author_id = models.IntegerField()
author_name = models.CharField()
author = models.ForeignObject(Author, models.CASCADE, ['author_id', 'author_name'], ['id', 'name'])
class Meta:
app_label = 'foo'
Running the following filter:
Book.objects.filter(author__isnull=True).query.__str__()
Will result in:
AttributeError: 'MultiColSource' object has no attribute 'as_sql'
> .../django/db/models/sql/compiler.py(366)compile()
365 else:
--> 366 sql, params = node.as_sql(self, self.connection)
367 if select_format and not self.subquery:
Change History (5)
comment:1 by , 10 years ago
| Has patch: | set |
|---|
comment:2 by , 10 years ago
comment:3 by , 10 years ago
| Severity: | Normal → Release blocker |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.
PR: https://github.com/django/django/pull/5858