# HG changeset patch # User Goffi # Date 1631116728 -7200 # Node ID bd13391ee29eecc833fb6a19f440c378638e7376 # Parent e4054b6481115ef115c756692faf52d1171eaa13 core (memory/sqla): fix `fileUpdate` diff -r e4054b648111 -r bd13391ee29e sat/memory/sqla.py --- a/sat/memory/sqla.py Wed Sep 08 17:58:48 2021 +0200 +++ b/sat/memory/sqla.py Wed Sep 08 17:58:48 2021 +0200 @@ -19,6 +19,7 @@ import sys import time import asyncio +import copy from datetime import datetime from asyncio.subprocess import PIPE from pathlib import Path @@ -981,14 +982,15 @@ )).scalar_one() except NoResultFound: raise exceptions.NotFound + old_value = copy.deepcopy(value) update_cb(value) - stmt = update(orm_col).filter_by(id=file_id) - if not value: + stmt = update(File).filter_by(id=file_id).values({column: value}) + if not old_value: # because JsonDefaultDict convert NULL to an empty dict, we have to - # test both for empty dict and None when we have and empty dict - stmt = stmt.where((orm_col == None) | (orm_col == value)) + # test both for empty dict and None when we have an empty dict + stmt = stmt.where((orm_col == None) | (orm_col == old_value)) else: - stmt = stmt.where(orm_col == value) + stmt = stmt.where(orm_col == old_value) result = await session.execute(stmt) await session.commit()