Opened 17 years ago
Closed 17 years ago
#6704 closed (fixed)
.exclude(foreignkey_field__isnull=True) doesn't quite work on qs-rf
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Uncategorized | Version: | queryset-refactor |
Severity: | Keywords: | qs-rf | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It gets turned into: (NOT table.foreignkey_field_id IS NULL OR table.foreignkey_field_id IS NULL) which of course is always going to be true :)
Haven't got my head around the code yet, but I'm guessing the following line is being run in this situation when it shouldn't be (I presume the line is intended for when a join is being done to get the required attribute on the related object, but for the special case of the id/pk field no join is needed and in fact no join was added):
self.where.add([alias, col, field, 'isnull', True], OR)
Change History (3)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
You can stop guessing. I'm working on this.
It is work in progress, so just bear with me for a little bit. A bunch of that code is being slightly rewritten to fix some other bugs, so this will be fixed in passing.
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I still haven't really got my head around the query stuff, but looking through a bit more I see where the optimisation is happening to remove the join 'cos it's the key field...
Does it matter that this code isn't also removing the join info from join_list (as join_list is processed by subsequent code in the function so)?
Anyway my guess at the fix (and it is a bit of a guess) for the exclude is_null bug is to tweak this bit of code to not fire if the lookup_type is "isnull" and value is True, although from the comment it may be Work In Progress anyway: