You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrated issue, originally created by Michael Bayer (@zzzeek)
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.declarative import declared_attr
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
data = Column(String)
bs = relationship("B")
class B(A):
__tablename__ = 'b'
id = Column(Integer, ForeignKey('a.id'), primary_key=True)
class C(A):
__tablename__ = 'c'
c_id = Column(Integer, ForeignKey('a.id'), primary_key=True)
from sqlalchemy.sql.elements import ClauseList
# ClauseList / Bundle are equivalent
print(ClauseList(A.id, C.c_id))
print(Bundle("pk", A.id, C.c_id).__clause_element__())
# w/ same name, they are not because it creates the clause list using *c without using exprs
print(ClauseList(A.id, B.id))
print(Bundle("pk", A.id, B.id).__clause_element__())
output:
a.id, c.c_id
a.id, c.c_id
a.id, b.id
b.id
fix:
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 98747c680..0b6b32a07 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -1738,7 +1738,7 @@ class Query(object):
self._group_by = False
return
- criterion = list(chain(*[_orm_columns(c) for c in criterion]))
+ criterion = c = list(chain(*[_orm_columns(c) for c in criterion]))
criterion = self._adapt_col_list(criterion)
if self._group_by is False:
@@ -3964,7 +3964,7 @@ class Bundle(InspectionAttr):
return cloned
def __clause_element__(self):
- return expression.ClauseList(group=False, *self.c)
+ return expression.ClauseList(group=False, *self.exprs)
@property
def clauses(self):
The text was updated successfully, but these errors were encountered:
Fixed bug in :class:.Bundle construct where placing two columns of the
same name would be de-duplicated, when the :class:.Bundle were used as
part of the rendered SQL, such as in the ORDER BY or GROUP BY of the statement.
Fixed bug in :class:.Bundle construct where placing two columns of the
same name would be de-duplicated, when the :class:.Bundle were used as
part of the rendered SQL, such as in the ORDER BY or GROUP BY of the statement.
Change-Id: Ia528c9fbb399a6beb5ea7cdd3a8a83ad530f5831
Fixes: #4295
(cherry picked from commit 2fdf260)
Migrated issue, originally created by Michael Bayer (@zzzeek)
output:
fix:
The text was updated successfully, but these errors were encountered: