Skip to content

Commit 4b23a6c

Browse files
benjaomingtimgraham
authored andcommitted
Documented a current limitation of multiple table annotation; refs #10060.
1 parent 16f26de commit 4b23a6c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/topics/db/aggregation.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ of the ``annotate()`` clause is a ``QuerySet``; this ``QuerySet`` can be
184184
modified using any other ``QuerySet`` operation, including ``filter()``,
185185
``order_by()``, or even additional calls to ``annotate()``.
186186

187+
.. admonition:: If in doubt, inspect the SQL query!
188+
189+
In order to understand what happens in your query, consider inspecting the
190+
``query`` property of your ``QuerySet``.
191+
192+
For instance, combining multiple aggregations with ``annotate()`` will
193+
yield the wrong results, as `multiple tables are the cross joined`_,
194+
resulting in duplicate row aggregations.
195+
196+
.. _multiple tables are the cross joined: https://code.djangoproject.com/ticket/10060
197+
187198
Joins and aggregates
188199
====================
189200

0 commit comments

Comments
 (0)