Flush objects by ourselves before processing before_commit event

During commit processing, sqla automatically flushes objects.
However, it does so after dispatching the before_commit event,
while Neutron expects it happens before the event.  This
counter-intuitive behaviour might or might not be considered
a bug in sqla.  Anyway, it's better to be safe in our side.

Closes-Bug: #1678726
Change-Id: Iceaf178be2885b0299d6d281983e9f7f8ae6def0
This commit is contained in:
YAMAMOTO Takashi 2017-04-03 19:31:32 +09:00 committed by Ihar Hrachyshka
parent d28a33a898
commit 9a0907dbb9
1 changed files with 4 additions and 1 deletions

View File

@ -278,7 +278,10 @@ def load_one_to_manys(session):
# have eliminated all places where related objects are constructed
# using a key rather than a relationship.
add_to_rel_load_list(session) # capture any new objects
# capture any new objects
if session.new:
session.flush()
if session.transaction.nested:
# wait until final commit
return