exclude() bug when used with Q() objects
|Reported by:||mucisland||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.1|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
.exclude() behaves different when its argument is wrapped into Q(). Specifically, when wrapping an exclude filter with Q(), objects containing NULL in related fields are excluded as well as objects which have matching content in this field.
The SQL which is generated by exclude(<field>=<value>) should _not_ match objects with NULL in the respective field, but this is sometimes violated when wrapping the filter with Q(). (So far I've only seen this bug when using a filter which specifies a field in a related object.)
The attached file contains a minimum Django project (project name is "sandbox", application name is "q") with two test cases which should clarify the described behaviour.
Change History (6)
comment:2 Changed 4 years ago by
comment:3 Changed 4 years ago by
|Status:||closed → new|
|Triage Stage:||Unreviewed → Accepted|