mapper not compiled automatically
Issue #555
resolved
{{{
Traceback (most recent call last):
File "t8.py", line 13, in <module>
session.connect(m)
File "sqlalchemy/lib/sqlalchemy/orm/session.py", line 148, in connect
return self.get_bind(mapper).connect(**kwargs)
File "sqlalchemy/lib/sqlalchemy/orm/session.py", line 265, in get_bind
elif self.binds.has_key(mapper.mapped_table):
AttributeError: 'Mapper' object has no attribute 'mapped_table'
#!python
from sqlalchemy import *
metadata = MetaData()
t = Table('foo', metadata, Column('id', Integer, primary_key=True))
class Foo(object): pass
m = mapper(Foo, t)
engine = create_engine('sqlite:///')
metadata.connect(engine)
session = create_session()
# m.compile() # <- must
session.connect(m)
Comments (2)
-
repo owner -
repo owner - changed status to resolved
- Log in to comment
we've moved (or at least, im trying to move) everyone to the idea that in order to get at a mapper, you say
class_mapper(someclass)
, which compiles. but that doesn't account for non-primary mappers anyway.i wonder, if something goofy like a
compile()
step within__getattr__()
might be a way to generically handle this, without forcing all attributes to do "if not compiled:compile()" ?