Update method improved in db api

Model is fetched from db in a separate session after update.
It is important to reload an entry, so that is has a correct updated_at
column.

Change-Id: Ia19139dd66ff0e3d412d13505d568545694e4ea7
This commit is contained in:
Nikita Konovalov 2014-06-09 15:55:49 +04:00
parent e30e1cb406
commit d8a90a03bd

View File

@ -225,9 +225,14 @@ def entity_update(kls, entity_id, values):
if entity is None:
raise exc.NotFound("%s %s not found" % (kls.__name__, entity_id))
entity.update(values.copy())
values_copy = values.copy()
values_copy["id"] = entity_id
entity.update(values_copy)
session.add(entity)
session = get_session()
entity = __entity_get(kls, entity_id, session)
return entity