Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#12598 closed (duplicate)

somefield__isnull=False produce wrong SQL

Reported by: benc Owned by:
Component: Database layer (models, ORM) Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (2)

comment:1 by Alex Gaynor, 14 years ago

Resolution: duplicate
Status: newclosed

Dupe of #12567.

comment:2 by Anssi Kääriäinen, 11 years ago

Component: ORM aggregationDatabase layer (models, ORM)
Note: See TracTickets for help on using tickets.
Back to Top