- attached 448.py
Cannot use a "join_to" on a SelectResults on a property of an inherited mapper
Traceback (most recent call last):
File "new.py", line 108, in ?
for activeEngineer in SelectResults(session.query(Engineer)).join_to('status').select(status.c.name=="active"):
File "build/bdist.linux-i686/egg/sqlalchemy/ext/selectresults.py", line 169, in __iter__
File "build/bdist.linux-i686/egg/sqlalchemy/orm/query.py", line 258, in select_whereclause
File "build/bdist.linux-i686/egg/sqlalchemy/orm/query.py", line 384, in _select_statement
File "build/bdist.linux-i686/egg/sqlalchemy/orm/query.py", line 314, in execute
File "build/bdist.linux-i686/egg/sqlalchemy/orm/session.py", line 133, in execute
File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 263, in execute
File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 287, in execute_clauseelement
File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 303, in execute_compiled
File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 299, in proxy
File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 337, in _execute_raw
File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 356, in _execute
sqlalchemy.exceptions.SQLError: (OperationalError) no such column: employee_join.status_id "SELECT people.person_id AS people_person_id, engineers.person_id AS engineers_person_id, engineers.field AS engineers_field, people.name AS people_name, people.status_id AS people_status_id \nFROM people JOIN engineers ON people.person_id = engineers.person_id JOIN status ON status.status_id = employee_join.status_id, (SELECT managers.person_id, managers.category, CAST(NULL AS VARCHAR(30)) AS field, people.name, people.status_id, 'manager' AS type \nFROM people JOIN managers ON people.person_id = managers.person_id UNION ALL SELECT engineers.person_id, CAST(NULL AS VARCHAR(70)) AS category, engineers.field, people.name, people.status_id, 'engineer' AS type \nFROM people JOIN engineers ON people.person_id = engineers.person_id) AS employee_join \nWHERE status.name = ? ORDER BY people.oid" ['active']('active')
This is certainly caused by 2270 from #441
See the file I will attach immediately
Easily tested using the testsuite and modifying in source:trunk/test/orm/inheritance5.py :
for activePerson in SelectResults(session.query(Person)).join_to('status').select(status.c.name=="active"):
by:
for activeEngineer in SelectResults(session.query(Engineer)).join_to('status').select(status.c.name=="active"):
IMPORTANT
Note that the error does not occur if you append the new ''for-statement'' after the first one (for activePerson...). The {{{SelectResults().join_to().select()}}} on the inherited mapper has to be the first one!
Comments (4)
-
Account Deleted -
repo owner just so you know we're going to have a lot of these since its pretty new territory. i wouldnt base anything mission-critical on polymorphic selects just yet since theres a lot more to be done with them (still marked as alpha on the site ! :) ).
-
repo owner - changed status to resolved
thank you, made some adjustments in changeset:2285 and appended the extra test condition to the existing unit tests in inheritance5.py. also added assertion conditions and made the select clause a little more complicated.
-
repo owner - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment
Testing script