From a6c2a3e47fb3657d64eb70e9ee298ce1355baf86 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 1 Jun 2021 13:02:03 +0930 Subject: [PATCH] Use synchronize_session="fetch" when updating values. --- gns3server/db/repositories/computes.py | 5 ++++- gns3server/db/repositories/templates.py | 5 ++++- gns3server/db/repositories/users.py | 10 ++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gns3server/db/repositories/computes.py b/gns3server/db/repositories/computes.py index 445621da..01b5ef10 100644 --- a/gns3server/db/repositories/computes.py +++ b/gns3server/db/repositories/computes.py @@ -79,7 +79,10 @@ class ComputesRepository(BaseRepository): if password: update_values["password"] = password.get_secret_value() - query = update(models.Compute).where(models.Compute.compute_id == compute_id).values(update_values) + query = update(models.Compute).\ + where(models.Compute.compute_id == compute_id).\ + values(update_values).\ + execution_options(synchronize_session="fetch") await self._db_session.execute(query) await self._db_session.commit() diff --git a/gns3server/db/repositories/templates.py b/gns3server/db/repositories/templates.py index e5be7971..999383e0 100644 --- a/gns3server/db/repositories/templates.py +++ b/gns3server/db/repositories/templates.py @@ -70,7 +70,10 @@ class TemplatesRepository(BaseRepository): update_values = template_update.dict(exclude_unset=True) - query = update(models.Template).where(models.Template.template_id == template_id).values(update_values) + query = not update(models.Template). \ + where(models.Template.template_id == template_id). \ + values(update_values).\ + execution_options(synchronize_session="fetch") await self._db_session.execute(query) await self._db_session.commit() diff --git a/gns3server/db/repositories/users.py b/gns3server/db/repositories/users.py index c93c741e..a7047ada 100644 --- a/gns3server/db/repositories/users.py +++ b/gns3server/db/repositories/users.py @@ -80,7 +80,10 @@ class UsersRepository(BaseRepository): if password: update_values["hashed_password"] = self._auth_service.hash_password(password=password.get_secret_value()) - query = update(models.User).where(models.User.user_id == user_id).values(update_values) + query = update(models.User).\ + where(models.User.user_id == user_id).\ + values(update_values).\ + execution_options(synchronize_session="fetch") await self._db_session.execute(query) await self._db_session.commit() @@ -151,7 +154,10 @@ class UsersRepository(BaseRepository): ) -> Optional[models.UserGroup]: 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) + query = update(models.UserGroup).\ + where(models.UserGroup.user_group_id == user_group_id).\ + values(update_values).\ + execution_options(synchronize_session="fetch") await self._db_session.execute(query) await self._db_session.commit()