Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#12597 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: UI/UX:



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(model2isnull=False)
which result with a SQL
WHERE "myapp_model0"."id" IS NOT NULL

objects = list(Model0.objects.filter(model2isnull=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.


Change History (2)

comment:1 Changed 8 years ago by Russell Keith-Magee

Resolution: duplicate
Status: newclosed

Duplicate of #12598

comment:2 Changed 5 years ago by Anssi Kääriäinen

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