Session rollback fails to undo an attribute change.
Issue #3072
closed
Calling session.rollback() while following along with the ORM tutorial failed to revert the user name from 'Edwardo' back to 'ed'.
Comments (2)
-
repo owner -
repo owner - changed status to closed
attribute changes are only rolled back based on what the DB has available.
- Log in to comment
The User object here is not present in the database after the rollback, and whatever data is inside of it is gone. There's no way to get the "ed" back. when the rollback happens, technically it might be more "correct" to just erase everything inside the User object that's created, since the INSERT, if any, was cancelled (in this case there's not even an INSERT unless you said session.flush()). But that's a little heavy handed, so whatever state was present on the non-inserted row just stays there:
to see the rollback, you need to roll back to a row that is persistent: