django1/django/db
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
..
backends Fixed #20010 -- Make sure `last_executed_query` contains it's associated parameters on Oracle. 2013-03-11 17:30:23 -04:00
models Refactored qs.add_q() and utils/tree.py 2013-03-13 10:44:49 +02:00
__init__.py Added some assertions to enforce the atomicity of atomic. 2013-03-11 14:48:55 +01:00
transaction.py Fixed #20028 -- Made atomic usable on callable instances. 2013-03-12 10:52:16 +01:00
utils.py Deprecated TransactionMiddleware and TRANSACTIONS_MANAGED. 2013-03-11 15:04:05 +01:00