Opened 5 years ago

Closed 5 years ago

Last modified 2 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 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #12598

comment:2 Changed 2 years ago by akaariai

  • Component changed from ORM aggregation to Database layer (models, ORM)
Note: See TracTickets for help on using tickets.
Back to Top