summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/firebird/base.py3
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py12
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py21
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py2
4 files changed, 18 insertions, 20 deletions
diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py
index a43413780..5779ac885 100644
--- a/lib/sqlalchemy/dialects/firebird/base.py
+++ b/lib/sqlalchemy/dialects/firebird/base.py
@@ -525,8 +525,7 @@ class FBCompiler(sql.compiler.SQLCompiler):
result += "FIRST %s " % self.process(select._limit_clause, **kw)
if select._offset_clause is not None:
result += "SKIP %s " % self.process(select._offset_clause, **kw)
- if select._distinct:
- result += "DISTINCT "
+ result += super(FBCompiler, self).get_select_precolumns(select, **kw)
return result
def limit_clause(self, select, **kw):
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index df6196bae..0dd2ac11b 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -1636,9 +1636,7 @@ class MSSQLCompiler(compiler.SQLCompiler):
def get_select_precolumns(self, select, **kw):
""" MS-SQL puts TOP, it's version of LIMIT here """
- s = ""
- if select._distinct:
- s += "DISTINCT "
+ s = super(MSSQLCompiler, self).get_select_precolumns(select, **kw)
if select._simple_int_limit and (
select._offset_clause is None
@@ -1649,12 +1647,8 @@ class MSSQLCompiler(compiler.SQLCompiler):
# so have to use literal here.
kw["literal_execute"] = True
s += "TOP %s " % self.process(select._limit_clause, **kw)
- if s:
- return s
- else:
- return compiler.SQLCompiler.get_select_precolumns(
- self, select, **kw
- )
+
+ return s
def get_from_hint_text(self, table, text):
return text
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 53c916304..38f3fa611 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -1450,19 +1450,22 @@ class MySQLCompiler(compiler.SQLCompiler):
def get_select_precolumns(self, select, **kw):
"""Add special MySQL keywords in place of DISTINCT.
- .. note::
-
- this usage is deprecated. :meth:`_expression.Select.prefix_with`
- should be used for special keywords at the start
- of a SELECT.
+ .. deprecated 1.4:: this usage is deprecated.
+ :meth:`_expression.Select.prefix_with` should be used for special
+ keywords at the start of a SELECT.
"""
if isinstance(select._distinct, util.string_types):
+ util.warn_deprecated(
+ "Sending string values for 'distinct' is deprecated in the "
+ "MySQL dialect and will be removed in a future release. "
+ "Please use :meth:`.Select.prefix_with` for special keywords "
+ "at the start of a SELECT statement",
+ version="1.4",
+ )
return select._distinct.upper() + " "
- elif select._distinct:
- return "DISTINCT "
- else:
- return ""
+
+ return super(MySQLCompiler, self).get_select_precolumns(select, **kw)
def visit_join(self, join, asfrom=False, from_linter=None, **kwargs):
if from_linter:
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 20540ac02..ca2f6a8a4 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1693,6 +1693,8 @@ class PGCompiler(compiler.SQLCompiler):
return "ONLY " + sqltext
def get_select_precolumns(self, select, **kw):
+ # Do not call super().get_select_precolumns because
+ # it will warn/raise when distinct on is present
if select._distinct or select._distinct_on:
if select._distinct_on:
return (