- changed status to resolved
as_scalar() not called on Query based subquery in column context
Issue #2190
resolved
i.e.
s.query(Parent).filter(Parent.id==s.query(Child.id).filter(Child.name=='foo'))
will render the scalar subquery in the FROM clause.
we do this already for non ORM queries.
patch:
--- a/lib/sqlalchemy/sql/expression.py Wed Jun 08 17:56:00 2011 -0400
+++ b/lib/sqlalchemy/sql/expression.py Sun Jun 12 20:20:25 2011 -0400
@@ -1943,7 +1943,10 @@
other.type = self.type
return other
elif hasattr(other, '__clause_element__'):
- return other.__clause_element__()
+ other = other.__clause_element__()
+ if isinstance(other, (_SelectBase, Alias)):
+ other = other.as_scalar()
+ return other
elif not isinstance(other, ClauseElement):
return self._bind_param(operator, other)
elif isinstance(other, (_SelectBase, Alias)):
Comments (2)
-
reporter -
reporter - removed milestone
Removing milestone: 0.7.2 (automated comment)
- Log in to comment
eaa7aa4239af4f42cdb8b370120d1538c6704d6b