1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Reconciling where- and having-clause behaviour.

Extricated the code that works directly with SQL columns (standard
"where" stuff) from the the code that takes SQL fragments and combines
it with lookup types and values. The latter portion is now more
generally reusable. Any existing code that was poking at Query.having
will now break in very visible ways (no subtle miscalculations, which is
a good thing).

This patch, en passant, removes the existing "having" test, since the
new implementation requires more setting up than previously. The
aggregates support (currently in a separate codebase) has tests for this
functionality that work as a replacement for the removed test.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9700 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2009-01-05 11:47:14 +00:00
parent ff4b844cb4
commit 062a94ef45
4 changed files with 101 additions and 77 deletions

View File

@@ -973,19 +973,6 @@ relations.
>>> len([x[2] for x in q.alias_map.values() if x[2] == q.LOUTER and q.alias_refcount[x[1]]])
1
A check to ensure we don't break the internal query construction of GROUP BY
and HAVING. These aren't supported in the public API, but the Query class knows
about them and shouldn't do bad things.
>>> qs = Tag.objects.values_list('parent_id', flat=True).order_by()
>>> qs.query.group_by = ['parent_id']
>>> qs.query.having = ['count(parent_id) > 1']
>>> expected = [t3.parent_id, t4.parent_id]
>>> expected.sort()
>>> result = list(qs)
>>> result.sort()
>>> expected == result
True
Make sure bump_prefix() (an internal Query method) doesn't (re-)break. It's
sufficient that this query runs without error.
>>> qs = Tag.objects.values_list('id', flat=True).order_by('id')