From d8a90a03bdfc4104cbb30c5cfad4208f144e3d55 Mon Sep 17 00:00:00 2001 From: Nikita Konovalov Date: Mon, 9 Jun 2014 15:55:49 +0400 Subject: [PATCH] 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 --- storyboard/db/api/base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/storyboard/db/api/base.py b/storyboard/db/api/base.py index 6d0bcaa7..58507a4e 100644 --- a/storyboard/db/api/base.py +++ b/storyboard/db/api/base.py @@ -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