summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py7
-rw-r--r--lib/sqlalchemy/sql/selectable.py4
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 627a4e01c..7e7c93527 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -542,6 +542,7 @@ class Query(object):
if with_labels:
q = q.with_labels()
q = q.statement
+
if reduce_columns:
q = q.reduce_columns()
return q.alias(name=name)
@@ -2381,6 +2382,12 @@ class Query(object):
need_adapter = False
+ if r_info.is_clause_element and right_selectable._is_lateral:
+ # orm_only is disabled to suit the case where we have to
+ # adapt an explicit correlate(Entity) - the select() loses
+ # the ORM-ness in this case right now, ideally it would not
+ right = self._adapt_clause(right, True, False)
+
if right_mapper and right is right_selectable:
if not right_selectable.is_derived_from(
right_mapper.mapped_table):
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
index 5b665829b..64886b326 100644
--- a/lib/sqlalchemy/sql/selectable.py
+++ b/lib/sqlalchemy/sql/selectable.py
@@ -338,6 +338,8 @@ class FromClause(Selectable):
_is_select = False
_is_from_container = False
+ _is_lateral = False
+
_textual = False
"""a marker that allows us to easily distinguish a :class:`.TextAsFrom`
or similar object from other kinds of :class:`.FromClause` objects."""
@@ -1329,6 +1331,7 @@ class Lateral(Alias):
"""
__visit_name__ = 'lateral'
+ _is_lateral = True
class TableSample(Alias):
@@ -3008,7 +3011,6 @@ class Select(HasPrefixes, HasSuffixes, GenerativeSelect):
# contents, as this set is used for matching, not rendering.
self._correlate = set(clone(f) for f in
self._correlate).union(self._correlate)
-
# 4. clone other things. The difficulty here is that Column
# objects are not actually cloned, and refer to their original
# .table, resulting in the wrong "from" parent after a clone