# HG changeset patch # User Goffi # Date 1556272646 -7200 # Node ID 21cf8395616ce8c9ad1255377e53c5d91d9caf33 # Parent adf6e33a3e5004721e4efd093129db5d23a5b7e6 memory (sqlite): fixed fileUpdate when original value is not set (NULL) diff -r adf6e33a3e50 -r 21cf8395616c sat/memory/sqlite.py --- a/sat/memory/sqlite.py Fri Apr 26 11:57:26 2019 +0200 +++ b/sat/memory/sqlite.py Fri Apr 26 11:57:26 2019 +0200 @@ -905,11 +905,18 @@ older_value_raw = cursor.fetchone()[0] except TypeError: raise exceptions.NotFound - value = json.loads(older_value_raw) + if older_value_raw is None: + value = {} + else: + value = json.loads(older_value_raw) update_cb(value) value_raw = json.dumps(value) - update_query = 'UPDATE files SET {column}=? WHERE id=? AND {column}=?'.format(column=column) - update_args = (value_raw, file_id, older_value_raw) + if older_value_raw is None: + update_query = 'UPDATE files SET {column}=? WHERE id=? AND {column} is NULL'.format(column=column) + update_args = (value_raw, file_id) + else: + update_query = 'UPDATE files SET {column}=? WHERE id=? AND {column}=?'.format(column=column) + update_args = (value_raw, file_id, older_value_raw) try: cursor.execute(update_query, update_args) except sqlite3.Error: