X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/move_up?a=blobdiff_plain;f=plomtask%2Fmisc.py;h=efa8898efd97d51ad685307902f135dc920c3ee7;hb=89624d5e05480c832a079008bbb9992f411be0dd;hp=dcaad175874c3d21041bd77fe0240f9060324cdd;hpb=33cff8c5f6427c4e7e617c459ee024b5b6c2d32e;p=plomtask diff --git a/plomtask/misc.py b/plomtask/misc.py index dcaad17..efa8898 100644 --- a/plomtask/misc.py +++ b/plomtask/misc.py @@ -46,8 +46,6 @@ class VersionedAttribute: def save(self, db_conn: DatabaseConnection) -> None: """Save as self.history entries, but first wipe old ones.""" - db_conn.exec(f'DELETE FROM {self.table_name} WHERE parent = ?', - (self.parent.id_,)) - for timestamp, value in self.history.items(): - db_conn.exec(f'INSERT INTO {self.table_name} VALUES (?, ?, ?)', - (self.parent.id_, timestamp, value)) + db_conn.rewrite_relations(self.table_name, 'parent', self.parent.id_, + [[item[0], item[1]] + for item in self.history.items()])