Closed
Description
Migrated issue, originally created by Anonymous
Currently, Index() can't be called with an object using the declarative layer. The result is:
AttributeError: 'InstrumentedAttribute' object has no attribute 'table'
However, using the columns directly works fine, but looks a bit ugly:
Index('viewforum', Topic.__table__.c.forum_id,
Topic.__table__.c.sticky, Topic.__table__.c.last_post_id)
Many thanks,[BR]
Christoph (aka tux21b)
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
sqlalchemy-bot commentedon Dec 21, 2008
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Jan 3, 2009
Michael Bayer (@zzzeek) wrote:
though this is problematic; if you say
Index('foo', MyClass.foo)
, its going to force compilation ofMyClass
' mapper, which can cause problems if dependent classes and tables have not yet been defined. We might further wantIndex
to defer getting the list of columns until create() is called, but then if your mapping has problems, you're going to have ORM errors withinmetadata.create_all()
which is pretty nasty.So it might be nice to get change the frigging
_CompileOnAttr
nastiness to be more of a completeInstrumentedAttribute
at mapper construction time. A quick workaround would be to put a working__clause_element__()
method on_CompileOnAttr
.sqlalchemy-bot commentedon Jan 3, 2009
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Jan 5, 2009
Anonymous wrote:
(original author: ged)
sqlalchemy-bot commentedon Jan 11, 2009
Michael Bayer (@zzzeek) wrote:
implemented in 209e888.
sqlalchemy-bot commentedon Jan 11, 2009
Changes by Michael Bayer (@zzzeek):