- changed status to invalid
expunge not fully effective?
Issue #861
resolved
Hi.
The attached code works with SQLAlchemy 0.3, but with SQLAlchemy 0.4 (from trunk) I get:
Traceback (most recent call last):
File "orm_expunge.py", line 67, in ?
transact(db, update, obj)
File "orm_expunge.py", line 27, in transact
ret = f(conn, sess, *args, **kwargs)
File "orm_expunge.py", line 54, in update
sess.save(oldobj)
File "/home/manlio/projects/svn-external/sqlalchemy/trunk/lib/sqlalchemy/orm/session.py", line 794, in save
self._save_impl(object, entity_name=entity_name)
File "/home/manlio/projects/svn-external/sqlalchemy/trunk/lib/sqlalchemy/orm/session.py", line 962, in _save_impl
raise exceptions.InvalidRequestError("Instance '%s' is already persistent" % mapperutil.instance_str(obj))
sqlalchemy.exceptions.InvalidRequestError: Instance 'Test@-0x4882bab4' is already persistent
Comments (1)
-
repo owner - Log in to comment
sorry, the test script is incorrect; save() is not meant to be used for persistent objects; use update() or save_or_update(). this is a recent change in trunk so that people dont get confused by the meaning of save() and as I've been telling people I might replace all three of save/update/save_or_update with a single "add()" method. below, we assert that the expunge worked and also use update():