summaryrefslogtreecommitdiff
path: root/test/sql/test_metadata.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-06-13 12:37:22 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-07-06 13:02:22 -0400
commitef7ff058eb67d73ebeac7b125ab2a7806e14629c (patch)
tree9a09162961f7bcdb6d16837adacabb99f10b4410 /test/sql/test_metadata.py
parent1ce98ca83a4b2da12e52aa0f4ab181c83063abc2 (diff)
downloadsqlalchemy-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/sql/test_metadata.py')
-rw-r--r--test/sql/test_metadata.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py
index 0d3a04430..5081cfbd2 100644
--- a/test/sql/test_metadata.py
+++ b/test/sql/test_metadata.py
@@ -2634,7 +2634,7 @@ class ConstraintTest(fixtures.TestBase):
def test_column_references_derived(self):
t1, t2, t3 = self._single_fixture()
- s1 = tsa.select([tsa.select([t1]).alias()])
+ s1 = tsa.select([tsa.select([t1]).alias()]).subquery()
assert t2.c.a.references(s1.c.a)
assert not t2.c.a.references(s1.c.b)
@@ -2646,7 +2646,7 @@ class ConstraintTest(fixtures.TestBase):
def test_derived_column_references(self):
t1, t2, t3 = self._single_fixture()
- s1 = tsa.select([tsa.select([t2]).alias()])
+ s1 = tsa.select([tsa.select([t2]).alias()]).subquery()
assert s1.c.a.references(t1.c.a)
assert not s1.c.a.references(t1.c.b)
@@ -2765,7 +2765,7 @@ class ConstraintTest(fixtures.TestBase):
Column("id", Integer, ForeignKey("t1.id"), primary_key=True),
)
- s = tsa.select([t2])
+ s = tsa.select([t2]).subquery()
t2fk = list(t2.c.id.foreign_keys)[0]
sfk = list(s.c.id.foreign_keys)[0]
@@ -3532,7 +3532,7 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase):
s = select([t1.select().alias()])
# proxy has goofy thing
- eq_(s.c.name.my_goofy_thing(), "hi")
+ eq_(s.subquery().c.name.my_goofy_thing(), "hi")
# compile works
self.assert_compile(
@@ -3561,7 +3561,7 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase):
"'test.sql.test_metadata..*MyColumn'> "
"object. Ensure the class includes a _constructor()",
getattr,
- select([t1.select().alias()]),
+ select([t1.select().alias()]).subquery(),
"c",
)