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 /lib/sqlalchemy/testing | |
| parent | e1a87f00123f97a6342af96ccc4b10a3ac51807e (diff) | |
| parent | 07d6d211f23f1d9d1d69fd54e8054bccd515bc8c (diff) | |
| download | sqlalchemy-f911e191d69e649ef8280309be9b0bb4d414d53d.tar.gz | |
Merge "Deprecate ``DISTINCT ON`` when not targeting PostgreSQL"
Diffstat (limited to 'lib/sqlalchemy/testing')
| -rw-r--r-- | lib/sqlalchemy/testing/assertions.py | 1 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/requirements.py | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/suite/test_select.py | 15 |
3 files changed, 20 insertions, 1 deletions
diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py index 61d272160..05dcf230b 100644 --- a/lib/sqlalchemy/testing/assertions.py +++ b/lib/sqlalchemy/testing/assertions.py @@ -412,7 +412,6 @@ class AssertsCompiledSQL(object): c = clause.compile(dialect=dialect, **kw) param_str = repr(getattr(c, "params", {})) - if util.py3k: param_str = param_str.encode("utf-8").decode("ascii", "ignore") print( diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index 644483b79..31011a970 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -1170,6 +1170,11 @@ class SuiteRequirements(Requirements): return exclusions.closed() @property + def supports_distinct_on(self): + """If a backend supports the DISTINCT ON in a select""" + return exclusions.closed() + + @property def supports_is_distinct_from(self): """Supports some form of "x IS [NOT] DISTINCT FROM y" construct. Different dialects will implement their own flavour, e.g., diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py index c1f77a7c1..ad17ebb4a 100644 --- a/lib/sqlalchemy/testing/suite/test_select.py +++ b/lib/sqlalchemy/testing/suite/test_select.py @@ -12,6 +12,7 @@ from ..schema import Column from ..schema import Table from ... import bindparam from ... import case +from ... import column from ... import Computed from ... import false from ... import func @@ -20,6 +21,7 @@ from ... import literal_column from ... import null from ... import select from ... import String +from ... import table from ... import testing from ... import text from ... import true @@ -1016,6 +1018,19 @@ class ComputedColumnTest(fixtures.TablesTest): eq_(res, [(100, 40), (1764, 168)]) +class DistinctOnTest(AssertsCompiledSQL, fixtures.TablesTest): + __backend__ = True + __requires__ = ("standard_cursor_sql",) + + @testing.fails_if(testing.requires.supports_distinct_on) + def test_distinct_on(self): + stm = select(["*"]).distinct(column("q")).select_from(table("foo")) + with testing.expect_deprecated( + "DISTINCT ON is currently supported only by the PostgreSQL " + ): + self.assert_compile(stm, "SELECT DISTINCT * FROM foo") + + class IsOrIsNotDistinctFromTest(fixtures.TablesTest): __backend__ = True __requires__ = ("supports_is_distinct_from",) |
