diff --git a/gns3server/db/repositories/computes.py b/gns3server/db/repositories/computes.py index 01b5ef10..b76842cb 100644 --- a/gns3server/db/repositories/computes.py +++ b/gns3server/db/repositories/computes.py @@ -81,12 +81,14 @@ class ComputesRepository(BaseRepository): query = update(models.Compute).\ where(models.Compute.compute_id == compute_id).\ - values(update_values).\ - execution_options(synchronize_session="fetch") + values(update_values) await self._db_session.execute(query) await self._db_session.commit() - return await self.get_compute(compute_id) + compute_db = await self.get_compute(compute_id) + if compute_db: + await self._db_session.refresh(compute_db) # force refresh of updated_at value + return compute_db async def delete_compute(self, compute_id: UUID) -> bool: diff --git a/gns3server/db/repositories/templates.py b/gns3server/db/repositories/templates.py index 999383e0..4e6f50b1 100644 --- a/gns3server/db/repositories/templates.py +++ b/gns3server/db/repositories/templates.py @@ -70,14 +70,16 @@ class TemplatesRepository(BaseRepository): update_values = template_update.dict(exclude_unset=True) - query = not update(models.Template). \ + query = update(models.Template). \ where(models.Template.template_id == template_id). \ - values(update_values).\ - execution_options(synchronize_session="fetch") + values(update_values) await self._db_session.execute(query) await self._db_session.commit() - return await self.get_template(template_id) + template_db = await self.get_template(template_id) + if template_db: + await self._db_session.refresh(template_db) # force refresh of updated_at value + return template_db async def delete_template(self, template_id: UUID) -> bool: diff --git a/gns3server/db/repositories/users.py b/gns3server/db/repositories/users.py index a7047ada..41c8d13d 100644 --- a/gns3server/db/repositories/users.py +++ b/gns3server/db/repositories/users.py @@ -82,12 +82,14 @@ class UsersRepository(BaseRepository): query = update(models.User).\ where(models.User.user_id == user_id).\ - values(update_values).\ - execution_options(synchronize_session="fetch") + values(update_values) await self._db_session.execute(query) await self._db_session.commit() - return await self.get_user(user_id) + user_db = await self.get_user(user_id) + if user_db: + await self._db_session.refresh(user_db) # force refresh of updated_at value + return user_db async def delete_user(self, user_id: UUID) -> bool: @@ -156,12 +158,14 @@ class UsersRepository(BaseRepository): update_values = user_group_update.dict(exclude_unset=True) query = update(models.UserGroup).\ where(models.UserGroup.user_group_id == user_group_id).\ - values(update_values).\ - execution_options(synchronize_session="fetch") + values(update_values) await self._db_session.execute(query) await self._db_session.commit() - return await self.get_user_group(user_group_id) + user_group_db = await self.get_user_group(user_group_id) + if user_group_db: + await self._db_session.refresh(user_group_db) # force refresh of updated_at value + return user_group_db async def delete_user_group(self, user_group_id: UUID) -> bool: