diff options
author | Federico Caselli <cfederico87@gmail.com> | 2020-04-16 23:16:32 +0200 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-04-20 11:28:51 -0400 |
commit | 07d6d211f23f1d9d1d69fd54e8054bccd515bc8c (patch) | |
tree | 321a19e49f8918ec38bba96bf4c062633801bd26 /lib/sqlalchemy/dialects/mysql/base.py | |
parent | 2f617f56f2acdce00b88f746c403cf5ed66d4d27 (diff) | |
download | sqlalchemy-07d6d211f23f1d9d1d69fd54e8054bccd515bc8c.tar.gz |
Deprecate ``DISTINCT ON`` when not targeting PostgreSQL
Deprecate usage of ``DISTINCT ON`` in dialect other than PostgreSQL.
Previously this was silently ignored.
Deprecate old usage of string distinct in MySQL dialect
Fixes: #4002
Change-Id: I38fc64aef75e77748083c11d388ec831f161c9c9
Diffstat (limited to 'lib/sqlalchemy/dialects/mysql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 21 |
1 files changed, 12 insertions, 9 deletions
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: |