diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-04-20 17:15:54 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-04-20 17:15:54 +0000 |
| commit | f911e191d69e649ef8280309be9b0bb4d414d53d (patch) | |
| tree | 26516fd09ed7d8db44902f59039b340cf60d600b /test | |
| parent | e1a87f00123f97a6342af96ccc4b10a3ac51807e (diff) | |
| parent | 07d6d211f23f1d9d1d69fd54e8054bccd515bc8c (diff) | |
| download | sqlalchemy-f911e191d69e649ef8280309be9b0bb4d414d53d.tar.gz | |
Merge "Deprecate ``DISTINCT ON`` when not targeting PostgreSQL"
Diffstat (limited to 'test')
| -rw-r--r-- | test/dialect/mysql/test_deprecations.py | 20 | ||||
| -rw-r--r-- | test/requirements.py | 5 | ||||
| -rw-r--r-- | test/sql/test_compiler.py | 7 |
3 files changed, 32 insertions, 0 deletions
diff --git a/test/dialect/mysql/test_deprecations.py b/test/dialect/mysql/test_deprecations.py index 544284a21..b2bd99d82 100644 --- a/test/dialect/mysql/test_deprecations.py +++ b/test/dialect/mysql/test_deprecations.py @@ -1,9 +1,29 @@ +from sqlalchemy import select +from sqlalchemy import table +from sqlalchemy.dialects.mysql import base as mysql from sqlalchemy.dialects.mysql import ENUM from sqlalchemy.dialects.mysql import SET +from sqlalchemy.testing import AssertsCompiledSQL +from sqlalchemy.testing import expect_deprecated from sqlalchemy.testing import expect_deprecated_20 from sqlalchemy.testing import fixtures +class CompileTest(AssertsCompiledSQL, fixtures.TestBase): + + __dialect__ = mysql.dialect() + + def test_distinct_string(self): + s = select(["*"]).select_from(table("foo")) + s._distinct = "foo" + + with expect_deprecated( + "Sending string values for 'distinct' is deprecated in the MySQL " + "dialect and will be removed in a future release" + ): + self.assert_compile(s, "SELECT FOO * FROM foo") + + class DeprecateQuoting(fixtures.TestBase): def test_enum_warning(self): ENUM("a", "b") diff --git a/test/requirements.py b/test/requirements.py index aac376dba..cf9168f5a 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -1611,3 +1611,8 @@ class DefaultRequirements(SuiteRequirements): @property def computed_columns_reflect_persisted(self): return self.computed_columns + skip_if("oracle") + + @property + def supports_distinct_on(self): + """If a backend supports the DISTINCT ON in a select""" + return only_if(["postgresql"]) diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index e44deed90..440eaa05a 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -1462,6 +1462,13 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): "SELECT count(DISTINCT mytable.myid) AS count_1 FROM mytable", ) + def test_distinct_on(self): + with testing.expect_deprecated( + "DISTINCT ON is currently supported only by the PostgreSQL " + "dialect" + ): + select(["*"]).distinct(table1.c.myid).compile() + def test_where_empty(self): self.assert_compile( select([table1.c.myid]).where( |
