Obviously I've used a very basic feature (rollback) without  knowing
exactly what it does. Even RTFM didn't clearify all.
-----------------------------------

Problem: Using the ORM, we delete an object x.
 Since another object (y) is referencing x, SA clears out the
ForeignKey in y pointing to x   (UPDATE y SET x_id=NULL WHERE ...)
But the UPDATE fails. We catch it and rollback the transaction.

Any following flush() will repeat the UPDATE (and fail again forever).
Obviously, rollback did not bring the Session in the state it had
before the transaction.

Currently, my only solution is to combine Session.rollback() with
Session.clear().
The application obviously cannot lean back and enjoy the rollback()
doing all the work.  After clear(), the previous Session state has to
be restored, resulting in a plenty of preventive save_or_update()
calls.

-- ->  Am I right that rollback() does not restore a Sessions pre-
transactional state ? Is rollback() followed by Session.clear() the
best solution ?
Thank you,
 Ruben


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

Reply via email to