- changed status to resolved
cannot alias a select which uses text for the from_obj. This used to work fine in 0.3.9
Issue #975
resolved
I want to create a select object onto a view or table in the database which doesn't have a full sqlalchemy Table definition. I can do this using the text() feature to create a select object which referenced my table in plain text.
However, a problem arises if I want to then use this select as a subselect of another query. To do this, my select must have an alias. However, in 0.4.3 this causes an error which was not present in 0.3.9. The issue can be illustrated with a single line of code:
textselect = select(['col1','col2']('col1','col2'), from_obj = 'tablename').alias('myalias')
which throws the error
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "c:\python25\lib\site-packages\sqlalchemy-0.4.3-py2.5.egg\sqlalchemy\sql\
expression.py", line 1605, in alias
return Alias(self, name)
File "c:\python25\lib\site-packages\sqlalchemy-0.4.3-py2.5.egg\sqlalchemy\sql\
expression.py", line 2396, in __init__
if self.selectable.oid_column is not None:
File "c:\python25\lib\site-packages\sqlalchemy-0.4.3-py2.5.egg\sqlalchemy\sql\
expression.py", line 3367, in oid_column
oid = f.oid_column
AttributeError: '_TextFromClause' object has no attribute 'oid_column'
It is not possible to set an oid_column property on the select or the from clause. On the select it is a read only property, and the _TextFromClause has no such property.
Comments (1)
-
repo owner - Log in to comment
thanks for the bug report, this issue is fixed in 7f43bc55e027b6419ac5a9893515ad9581c98538 with some test coverage added.
If any problems arise within the ORM stage of things feel free to post to the mailing list or open more tickets.