1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-26 16:58:28 +00:00

Use synchronize_session="fetch" when updating values.

This commit is contained in:
grossmj 2021-06-01 13:02:03 +09:30
parent 91b0534182
commit a6c2a3e47f
3 changed files with 16 additions and 4 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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()