I've generated a test data set and then want to have all of the
created objects and relationships available for reference easily.
To avoid possible pollution of this fixture I want to detach the
objects from the sessions to avoid them getting any updates applied.

To do this I am attempting to load all data via joinedload and then
calling session.expunge_all:

    print assets['test_asset_1'].attributes # OK
 
session.query(Asset).options(joinedload(Asset.asset_attributes)).populate_existing().all()
    session.expunge_all()
    print assets['test_asset_1'].attributes # ERROR

None of the relationships on the objects survive the expunge.

    sqlalchemy.orm.exc.DetachedInstanceError:
    Parent instance <Asset at ...> is not bound to a Session;
    lazy load operation of attribute 'asset_attributes' cannot proceed

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to