[Sqlalchemy-tickets] Issue #3409: 0.9.x - 1.0.x regression - AttributeError: entity when using labe
Brought to you by:
zzzeek
|
From: Pavel B. <iss...@bi...> - 2015-05-01 08:37:32
|
New issue 3409: 0.9.x - 1.0.x regression - AttributeError: entity when using label() with attribute of aliased entity https://bitbucket.org/zzzeek/sqlalchemy/issue/3409/09x-10x-regression-attributeerror-entity Pavel Brych: After upgrading to 1.0.2 resp. 1.0.3 SQLAlchemy, this error popped up. It happens when label() is used with attribute of aliased entity. ``` #!python #!/usr/bin/python # -*- coding: utf-8 -*- from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import aliased Base = declarative_base() class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) username = Column(String(255)) realname = Column(String(255)) e = create_engine("postgresql://user:passwd@localhost/db_name", echo=True) Base.metadata.create_all(e) session = Session(e) user = aliased(User,name="user") q = session.query(user.username.label("username")) print(q.column_descriptions) ``` ``` #!python Traceback (most recent call last): File "/home/pavel/python/hores/src/sqlalchemytest.py", line 27, in <module> print(q.column_descriptions) File "/usr/lib64/python3.4/site-packages/sqlalchemy/orm/query.py", line 2583, in column_descriptions for ent in self._entities File "/usr/lib64/python3.4/site-packages/sqlalchemy/orm/query.py", line 2583, in <listcomp> for ent in self._entities File "/usr/lib64/python3.4/site-packages/sqlalchemy/orm/util.py", line 398, in __getattr__ raise AttributeError(key) AttributeError: entity ``` |