On Dec 6, 4:49 pm, Ian Thompson <quorn...@gmail.com> wrote:
> 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_e 
> xisting().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
(cont...)
Is there a correct way to detach all current data from the Session
fully loading any relationships? (Small data set so memory is not a
concern.)

Ian

-- 
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