Index() throws an AttributeError when called with an object using declarative base
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)
Comments (5)
-
repo owner -
repo owner - changed milestone to 0.5.xx
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
. -
Account Deleted - changed watchers to ged@openhex.org
(original author: ged)
-
repo owner - changed status to resolved
implemented in 209e888e1bda69924b364ae3394016acef0e9d41.
-
repo owner - removed milestone
Removing milestone: 0.5.xx (automated comment)
- Log in to comment