django1/django
Anssi Kääriäinen d3f00bd570 Refactored qs.add_q() and utils/tree.py
The sql/query.py add_q method did a lot of where/having tree hacking to
get complex queries to work correctly. The logic was refactored so that
it should be simpler to understand. The new logic should also produce
leaner WHERE conditions.

The changes cascade somewhat, as some other parts of Django (like
add_filter() and WhereNode) expect boolean trees in certain format or
they fail to work. So to fix the add_q() one must fix utils/tree.py,
some things in add_filter(), WhereNode and so on.

This commit also fixed add_filter to see negate clauses up the path.
A query like .exclude(Q(reversefk__in=a_list)) didn't work similarly to
.filter(~Q(reversefk__in=a_list)). The reason for this is that only
the immediate parent negate clauses were seen by add_filter, and thus a
tree like AND: (NOT AND: (AND: condition)) will not be handled
correctly, as there is one intermediary AND node in the tree. The
example tree is generated by .exclude(~Q(reversefk__in=a_list)).

Still, aggregation lost connectors in OR cases, and F() objects and
aggregates in same filter clause caused GROUP BY problems on some
databases.

Fixed #17600, fixed #13198, fixed #17025, fixed #17000, fixed #11293.
2013-03-13 10:44:49 +02:00
..
bin Advanced pending deprecation warnings. 2012-12-29 21:59:07 +01:00
conf Fixed #16888 -- Added microseconds in localized input formats 2013-03-02 19:04:23 +01:00
contrib Refactored qs.add_q() and utils/tree.py 2013-03-13 10:44:49 +02:00
core Fixed a refactoring error in ba5138b1. 2013-03-11 22:40:13 +01:00
db Refactored qs.add_q() and utils/tree.py 2013-03-13 10:44:49 +02:00
dispatch Fixed #19634 -- Added proper __hash__ methods. 2013-02-25 23:05:20 +01:00
forms Fixed a regression in forms changed_data 2013-03-08 18:19:24 +01:00
http Fixed #20019 -- Ensured HttpRequest.resolver_match always exists. 2013-03-10 23:28:19 +01:00
middleware Deprecated TransactionMiddleware and TRANSACTIONS_MANAGED. 2013-03-11 15:04:05 +01:00
shortcuts Fixed #19692 -- Completed deprecation of mimetype in favor of content_type. 2013-01-31 13:54:40 +01:00
template [py3] Always fed hashlib with bytes. 2013-02-27 10:02:07 +01:00
templatetags Fixed #19915 - Made blocktrans tag honor TEMPLATE_STRING_IF_INVALID. 2013-03-03 16:10:11 -03:00
test Abused atomic for transaction handling in TestCase. 2013-03-11 15:05:05 +01:00
utils Refactored qs.add_q() and utils/tree.py 2013-03-13 10:44:49 +02:00
views Loaded cycle and firstof from future in built-in templates. Refs #17906. 2013-02-24 15:16:45 +01:00
__init__.py Advanced version identifiers for 1.6 cycle. 2012-10-26 22:01:34 -03:00