[Django] #25972: Filtering a ForeignObject with 'isnull' lookup fails in Django 1.9

10 views
Skip to first unread message

Django

unread,
Dec 22, 2015, 6:35:42 PM12/22/15
to django-...@googlegroups.com
#25972: Filtering a ForeignObject with 'isnull' lookup fails in Django 1.9
----------------------------------------------+---------------------------
Reporter: tomo-otsuka | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.9
Severity: Normal | Keywords: ForeignObject
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+---------------------------
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:
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25972>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 22, 2015, 6:43:53 PM12/22/15
to django-...@googlegroups.com
#25972: Filtering a ForeignObject with 'isnull' lookup fails in Django 1.9
-------------------------------------+-------------------------------------

Reporter: tomo-otsuka | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Normal | Resolution:

Keywords: ForeignObject | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by tomo-otsuka):

* needs_better_patch: => 0
* has_patch: 0 => 1
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/25972#comment:1>

Django

unread,
Dec 22, 2015, 7:01:52 PM12/22/15
to django-...@googlegroups.com
#25972: Filtering a ForeignObject with 'isnull' lookup fails in Django 1.9
-------------------------------------+-------------------------------------

Reporter: tomo-otsuka | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ForeignObject | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by tomo-otsuka):

PR: https://github.com/django/django/pull/5858

--
Ticket URL: <https://code.djangoproject.com/ticket/25972#comment:2>

Django

unread,
Dec 22, 2015, 7:38:40 PM12/22/15
to django-...@googlegroups.com
#25972: Filtering a ForeignObject with 'isnull' lookup fails in Django 1.9
-------------------------------------+-------------------------------------

Reporter: tomo-otsuka | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: ForeignObject | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/25972#comment:3>

Django

unread,
Dec 24, 2015, 7:35:24 AM12/24/15
to django-...@googlegroups.com
#25972: Filtering a ForeignObject with 'isnull' lookup fails in Django 1.9
-------------------------------------+-------------------------------------
Reporter: tomo-otsuka | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Release blocker | Resolution: fixed

Keywords: ForeignObject | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"8b6974a6857bdc48ad50bf21527b840c27648891" 8b6974a]:
{{{
#!CommitTicketReference repository=""
revision="8b6974a6857bdc48ad50bf21527b840c27648891"
Fixed #25972 -- Restored support for the isnull lookup with ForeignObject.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25972#comment:4>

Django

unread,
Dec 24, 2015, 7:38:28 AM12/24/15
to django-...@googlegroups.com
#25972: Filtering a ForeignObject with 'isnull' lookup fails in Django 1.9
-------------------------------------+-------------------------------------
Reporter: tomo-otsuka | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: ForeignObject | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"bc5eed8fb0c4182a0f84eb78e729f05246312d84" bc5eed8f]:
{{{
#!CommitTicketReference repository=""
revision="bc5eed8fb0c4182a0f84eb78e729f05246312d84"
[1.9.x] Fixed #25972 -- Restored support for the isnull lookup with
ForeignObject.

Backport of 8b6974a6857bdc48ad50bf21527b840c27648891 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25972#comment:5>

Reply all
Reply to author
Forward
0 new messages