problems with eager loading and inheritance

Issue #486 resolved
Former user created an issue

I have attached a test script that reproduces the problem.

On Debian Etch, with SQLAlchemy python-sqlalchemy_0.3.4-2_all, and Python 2.4 I got:

manlio@synapsis:~/projects/bugs/sqlalchemy$ python inheritance.py x u'comment' xx Traceback (most recent call last): File "inheritance.py", line 117, in ? view(o) File "inheritance.py", line 86, in wrap return db.transaction(_job, None, args, kwargs) File "/usr/lib/python2.4/site-packages/sqlalchemy/engine/base.py", line 457, in transaction ret = callable_(conn, args, kwargs) File "inheritance.py", line 77, in _job ret = f(conn, sess, *args, kwargs) File "inheritance.py", line 105, in view print for c in o.comments File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/attributes.py", line 48, in get return self.get(obj) File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/attributes.py", line 183, in get values = callable() File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/strategies.py", line 207, in lazyload raise exceptions.InvalidRequestError("Parent instance %s is not bound to a Session, and no contextual session is established; lazy load operation of attribute '%s' cannot proceed" % (instance.class, self.key)) sqlalchemy.exceptions.InvalidRequestError: Parent instance <class 'main.DerivedII'> is not bound to a Session, and no contextual session is established; lazy load operation of attribute 'comments' cannot proceed

Thanks

Comments (1)

  1. Log in to comment