#6704: .exclude(foreignkey_field__isnull=True) doesn't quite work on qs-rf
---------------------------------+------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: nobody
Status: new | Component: Uncategorized
Version: queryset-refactor | Resolution:
Keywords: qs-rf | Stage: Unreviewed
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
---------------------------------+------------------------------------------
Changes (by [EMAIL PROTECTED]):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
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...
{{{
if join_list:
# An optimization: if the final join is against the same
column as
# we are comparing against, we can go back one step in the
join
# chain and compare against the lhs of the join instead. The
result
# (potentially) involves one less table join.
join = self.alias_map[alias][ALIAS_JOIN]
if col == join[RHS_JOIN_COL]:
self.unref_alias(alias)
alias = join[LHS_ALIAS]
col = join[LHS_JOIN_COL]
}}}
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:
{{{
if flag:
# XXX: Change this to the field we joined against to allow
# for node sharing and where-tree optimisation?
self.where.add([alias, col, field, 'isnull', True], OR)
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/6704#comment:1>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---