We using block 'with session.begin()' to organize some operations in
one transaction. session.begin() returns a transaction instance, then
does some operations, and will commit or rollback automatically
before leaving the block. ModelBase.save() always submit a commit,
and that is not expected.
When we get a persistent object from database, we just modify the
object inside of block 'with session.begin()' and sqlalchemy will
update it,don't need method session.add() or ModelBase.save()
Reviewed: https:/ /review. openstack. org/46258 github. com/stackforge/ savanna/ commit/ 9390ce7b035a7d6 0d0c665dc0891b6 7f7436e8f3
Committed: http://
Submitter: Jenkins
Branch: master
commit 9390ce7b035a7d6 0d0c665dc0891b6 7f7436e8f3
Author: Chang Bo Guo <email address hidden>
Date: Thu Sep 12 04:45:31 2013 -0700
Don't use ModelBase.save() inside of transaction
We using block 'with session.begin()' to organize some operations in
one transaction. session.begin() returns a transaction instance, then
does some operations, and will commit or rollback automatically
before leaving the block. ModelBase.save() always submit a commit,
and that is not expected.
When we get a persistent object from database, we just modify the
object inside of block 'with session.begin()' and sqlalchemy will
update it,don't need method session.add() or ModelBase.save()
Fixes bug #1224429
Change-Id: I2204b3023c01e6 5950e6131cd08b4 ded5564e9b9