Opened 7 years ago

Closed 7 years ago

Last modified 4 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:

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(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.

Thanks

Change History (2)

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

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: duplicate
Status: newclosed

Duplicate of #12598

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

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