diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-08-31 13:13:04 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-08-31 13:13:27 -0400 |
commit | 2d48b9de5ad5b577c62e5ea8e810f241a31fbb4c (patch) | |
tree | 0d4e364090a553cbc2ff38ea4184e77b218e1957 | |
parent | 161209c70adde092e953d9ac7e3e7355a7df579a (diff) | |
download | sqlalchemy-2d48b9de5ad5b577c62e5ea8e810f241a31fbb4c.tar.gz |
- add a note about DISTINCT in query w/ ORDER BY, references #3518
(cherry picked from commit 6d0c0994e9a08cf5d149af0314970d5f6e25b159)
-rw-r--r-- | lib/sqlalchemy/orm/query.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index e9b4e1982..b5cd03002 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -2333,6 +2333,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. |