#7512: including a nullable foreign key reference in Meta ordering has
unexpected
results
----------------------------------------------------+-----------------------
Reporter: R. Bailey <[EMAIL PROTECTED]> | Owner: gav
Status: new | Milestone: 1.0
Component: Database wrapper | Version: SVN
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
----------------------------------------------------+-----------------------
Comment (by gav):
Well, besides add_filter, what other places should the promotion code be
added? Anything related to ordering, if it orders across a null FK, would
need the same handling code, correct?
The second test case in the attached patch still fails as of r8752.
Also, I'm not sure why this would create an outer join when add_filter()
isn't comparing against null values. By adding a "print names" to the
beginning of setup_joins(), I get this for the last unit test in the
attached patch:
{{{
Expected:
[<Comment: Another first comment>, <Comment: My second comment>,
<Comment: Another second comment>, <Comment: My first comment>]
Got:
names ['post', 'forum', 'system_info', 'system_name']
names ['comment_text']
[<Comment: Another second comment>, <Comment: My first comment>]
}}}
Those names are the only ones being used by ordering or filtering, so it's
not looking at all fields in the model, only the ones involved in the FK
path. So how would it be promoting a query to an outer join that it
shouldn't? If there's a null key in the relation at all, shouldn't it
always be promoted to an outer join? Even if it's on a filter that's not
explicitly requesting a {{{ __isnull }}} type check, if it generates any
relations, those should be pulled in as outer joins, not inner joins, no
matter the case, I would think. There's never a reason that a
FK(null=True) relationship should be pulled as an INNER JOIN that I can
think of.
Is this still on slate for 1.0? It does break code with any reliance on
FK(null=True) of a depth greater than one.
--
Ticket URL: <http://code.djangoproject.com/ticket/7512#comment:7>
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
-~----------~----~----~----~------~----~------~--~---