diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-02-10 14:17:08 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-02-10 14:17:08 -0500 |
| commit | 3f9a343d725eea883aba2145de4cbb7b84f9d08c (patch) | |
| tree | f55e890195c76543e689c3b939b84df15cd80a3e /lib/sqlalchemy/dialects | |
| parent | a6d54d18c1ddac30940affaa940edaad59e5d63f (diff) | |
| download | sqlalchemy-3f9a343d725eea883aba2145de4cbb7b84f9d08c.tar.gz | |
- Query.distinct() now accepts column expressions
as *args, interpreted by the Postgresql dialect
as DISTINCT ON (<expr>). [ticket:1069]
- select.distinct() now accepts column expressions
as *args, interpreted by the Postgresql dialect
as DISTINCT ON (<expr>). Note this was already
available via passing a list to the `distinct`
keyword argument to select(). [ticket:1069]
- select.prefix_with() accepts multiple expressions
(i.e. *expr), 'prefix' keyword argument to select()
accepts a list or tuple.
- Passing a string to the `distinct` keyword argument
of `select()` for the purpose of emitting special
MySQL keywords (DISTINCTROW etc.) is deprecated -
use `prefix_with()` for this.
- put kw arguments to select() in order
- restore docs for _SelectBase, renamed from _SelectBaseMixin
Diffstat (limited to 'lib/sqlalchemy/dialects')
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 7 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 271218dba..21e0312f5 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -1176,6 +1176,13 @@ class MySQLCompiler(compiler.SQLCompiler): return value def get_select_precolumns(self, select): + """Add special MySQL keywords in place of DISTINCT. + + .. note:: this usage is deprecated. :meth:`.Select.prefix_with` + should be used for special keywords at the start + of a SELECT. + + """ if isinstance(select._distinct, basestring): return select._distinct.upper() + " " elif select._distinct: diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 22d269cdf..8bc95ef48 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -457,11 +457,10 @@ class PGCompiler(compiler.SQLCompiler): return "DISTINCT " elif isinstance(select._distinct, (list, tuple)): return "DISTINCT ON (" + ', '.join( - [(isinstance(col, basestring) and col - or self.process(col)) for col in select._distinct] + [self.process(col) for col in select._distinct] )+ ") " else: - return "DISTINCT ON (" + unicode(select._distinct) + ") " + return "DISTINCT ON (" + self.process(select._distinct) + ") " else: return "" |
