diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-06-13 12:37:22 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-07-06 13:02:22 -0400 |
commit | ef7ff058eb67d73ebeac7b125ab2a7806e14629c (patch) | |
tree | 9a09162961f7bcdb6d16837adacabb99f10b4410 /test/base/test_utils.py | |
parent | 1ce98ca83a4b2da12e52aa0f4ab181c83063abc2 (diff) | |
download | sqlalchemy-ef7ff058eb67d73ebeac7b125ab2a7806e14629c.tar.gz |
SelectBase no longer a FromClause
As part of the SQLAlchemy 2.0 migration project, a conceptual change has
been made to the role of the :class:`.SelectBase` class hierarchy,
which is the root of all "SELECT" statement constructs, in that they no
longer serve directly as FROM clauses, that is, they no longer subclass
:class:`.FromClause`. For end users, the change mostly means that any
placement of a :func:`.select` construct in the FROM clause of another
:func:`.select` requires first that it be wrapped in a subquery first,
which historically is through the use of the :meth:`.SelectBase.alias`
method, and is now also available through the use of
:meth:`.SelectBase.subquery`. This was usually a requirement in any
case since several databases don't accept unnamed SELECT subqueries
in their FROM clause in any case.
See the documentation in this change for lots more detail.
Fixes: #4617
Change-Id: I0f6174ee24b9a1a4529168e52e855e12abd60667
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r-- | test/base/test_utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index fea34cf8d..d7e4deb28 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -9,6 +9,7 @@ from sqlalchemy import sql from sqlalchemy import testing from sqlalchemy import util from sqlalchemy.sql import column +from sqlalchemy.sql.base import SeparateKeyColumnCollection from sqlalchemy.testing import assert_raises from sqlalchemy.testing import assert_raises_message from sqlalchemy.testing import eq_ @@ -441,6 +442,29 @@ class ToListTest(fixtures.TestBase): ) +class SeparateKeysColumnCollectionTest( + testing.AssertsCompiledSQL, fixtures.TestBase +): + def test_in(self): + cc = SeparateKeyColumnCollection() + cc["kcol1"] = sql.column("col1") + cc["kcol2"] = sql.column("col2") + cc["kcol3"] = sql.column("col3") + assert "col1" not in cc + assert "kcol2" in cc + + def test_get(self): + c1, c2 = sql.column("col1"), sql.column("col2") + cc = SeparateKeyColumnCollection([("kcol1", c1), ("kcol2", c2)]) + is_(cc.kcol1, c1) + is_(cc.kcol2, c2) + + def test_all_cols(self): + c1, c2 = sql.column("col1"), sql.column("col2") + cc = SeparateKeyColumnCollection([("kcol1", c1), ("kcol2", c2)]) + eq_(cc._all_columns, [c1, c2]) + + class ColumnCollectionTest(testing.AssertsCompiledSQL, fixtures.TestBase): def test_in(self): cc = sql.ColumnCollection() |