django1/django/db/models
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
..
fields Fixed #19964 -- Removed relabel_aliases from some structs 2013-03-12 21:33:47 +02:00
sql Refactored qs.add_q() and utils/tree.py 2013-03-13 10:44:49 +02:00
__init__.py Removed unneeded imports in db.models init 2013-02-08 17:11:33 +01:00
aggregates.py Refactored qs.add_q() and utils/tree.py 2013-03-13 10:44:49 +02:00
base.py Deprecated transaction.commit/rollback_unless_managed. 2013-03-11 14:48:54 +01:00
constants.py Refactored qs.add_q() and utils/tree.py 2013-03-13 10:44:49 +02:00
deletion.py Used commit_on_success_unless_managed to make ORM operations atomic. 2013-03-11 15:05:05 +01:00
expressions.py Refactored qs.add_q() and utils/tree.py 2013-03-13 10:44:49 +02:00
loading.py Fixed #19689 -- Renamed `Model._meta.module_name` to `model_name`. 2013-02-05 04:16:07 -05:00
manager.py Fixed #15363 -- Renamed and normalized to `get_queryset` the methods that return a QuerySet. 2013-03-08 10:11:45 -05:00
options.py Fixed #19689 -- Renamed `Model._meta.module_name` to `model_name`. 2013-02-05 04:16:07 -05:00
query.py Used commit_on_success_unless_managed to make ORM operations atomic. 2013-03-11 15:05:05 +01:00
query_utils.py Refactored qs.add_q() and utils/tree.py 2013-03-13 10:44:49 +02:00
related.py Fixed #19689 -- Renamed `Model._meta.module_name` to `model_name`. 2013-02-05 04:16:07 -05:00
signals.py Added documentation for the 'db' argument of the post-syncdb signal. 2013-01-03 22:04:55 +01:00