Opened 15 years ago

Closed 15 years ago

Last modified 12 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: 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(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 by Russell Keith-Magee, 15 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #12598

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

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