summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/util.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 /lib/sqlalchemy/orm/util.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 'lib/sqlalchemy/orm/util.py')
-rw-r--r--lib/sqlalchemy/orm/util.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index 80d4b26b2..4b4fa4052 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -825,7 +825,9 @@ def aliased(element, alias=None, name=None, flat=False, adapt_on_names=False):
raise sa_exc.ArgumentError(
"adapt_on_names only applies to ORM elements"
)
- return element._anonymous_fromclause(name=name, flat=flat)
+ return coercions.expect(
+ roles.AnonymizedFromClauseRole, element, name=name, flat=flat
+ )
else:
return AliasedClass(
element,