]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add a note about DISTINCT in query w/ ORDER BY, references #3518
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 31 Aug 2015 17:13:04 +0000 (13:13 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 31 Aug 2015 17:13:04 +0000 (13:13 -0400)
lib/sqlalchemy/orm/query.py

index 5d08cbcd556aa1e1d25527f2dae5e49248268eb9..7e77c66a827caf54bca2e2930d3e7b7c06782158 100644 (file)
@@ -2335,6 +2335,19 @@ class Query(object):
         """Apply a ``DISTINCT`` to the query and return the newly resulting
         ``Query``.
 
+
+        .. note::
+
+            The :meth:`.distinct` call includes logic that will automatically
+            add columns from the ORDER BY of the query to the columns
+            clause of the SELECT statement, to satisfy the common need
+            of the database backend that ORDER BY columns be part of the
+            SELECT list when DISTINCT is used.   These columns *are not*
+            added to the list of columns actually fetched by the
+            :class:`.Query`, however, so would not affect results.
+            The columns are passed through when using the
+            :attr:`.Query.statement` accessor, however.
+
         :param \*expr: optional column expressions.  When present,
          the Postgresql dialect will render a ``DISTINCT ON (<expressions>>)``
          construct.