#7314 closed (fixed)
Combining querysets remove extra-Subquery
Reported by: | Erik Stein | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Keywords: | qsrf-cleanup nfa-someday | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If I combine two queries where the first one has an extra where clause defining a subquery, the subquery is removed from the resulting queryset. The queryset gives wrong results.
See attached test.
The method to combine queries this way is used in ChangeList.get_query_set
, see
source:/django/branches/newforms-admin/django/contrib/admin/views/main.py#7544#L306
Attachments (1)
Change History (7)
by , 17 years ago
comment:1 by , 17 years ago
Keywords: | nfa-someday added |
---|
comment:2 by , 17 years ago
Keywords: | qsrf-cleanup added |
---|
This looks to me more like a straight QuerySet problem, unrelated to NFA. Am I wrong? Tagging with qsrf-cleanup for now.
comment:3 by , 17 years ago
milestone: | → 1.0 |
---|
comment:4 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Version: | newforms-admin → SVN |
The line of code pointed to in the description doesn't use extra()
at all. Still, this is a semi-bug: we use only the extra bits from the RHS. I'll merge them together, but people shouldn't expect miracles when it comes to this always working, since Django isn't going to rewrite aliases in extra()
for you (that would require writing an SQL parser).
comment:5 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [7791]) Fixed #7314 -- Changed the way extra() bits are handled when QuerySets are merged.
Also added a section to the documentation to indicate why it's probably not a
good idea to rely on this feature for complex stuff. Garbage in, garbage out
applies even to Django code.
Thanks to erik for the test case for this one.
Code is same on trunk as nfa, should not block merge.