[Django] #12598: somefield__isnull=False produce wrong SQL

0 views
Skip to first unread message

Django

unread,
Jan 12, 2010, 7:37:51 PM1/12/10
to djang...@holovaty.com, django-...@googlegroups.com
#12598: somefield__isnull=False produce wrong SQL
-----------------------------+----------------------------------------------
Reporter: benc | Owner:
Status: new | Milestone:
Component: ORM aggregation | Version: 1.1
Keywords: | Stage: Unreviewed
Has_patch: 0 |
-----------------------------+----------------------------------------------
Hi

I have two models Model1 Model2, extending another model Model0(not
abstract).
I'm trying query Model0 and to filter only the models that have relation
to Model1


{{{
objects = list(Model0.objects.filter(model2__isnull=False)
}}}

which result with a SQL

{{{
WHERE "myapp_model0"."id" IS NOT NULL
}}}



{{{
objects = list(Model0.objects.filter(model2__isnull=True)
}}}

which result with a SQL

{{{
WHERE "myapp_model2"."model0_ptr_id" IS NULL'
}}}


The first SQL and the second is right.
When using ~Q to negate the second I get what I want.

Thanks

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

Django

unread,
Jan 12, 2010, 8:02:47 PM1/12/10
to djang...@holovaty.com, django-...@googlegroups.com
#12598: somefield__isnull=False produce wrong SQL
--------------------------------------+-------------------------------------
Reporter: benc | Owner:
Status: closed | Milestone:
Component: ORM aggregation | Version: 1.1
Resolution: duplicate | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------+-------------------------------------
Changes (by Alex):

* status: new => closed
* needs_better_patch: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_docs: => 0

Comment:

Dupe of #12567.

--
Ticket URL: <http://code.djangoproject.com/ticket/12598#comment:1>
Reply all
Reply to author
Forward
0 new messages