X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/form?a=blobdiff_plain;f=plomtask%2Fdb.py;h=3917ce0558e3f7deb1f917a07eb5dd4df7b279e6;hb=eba83bdbf91206ad3af19810f27ca6e24e484555;hp=054060e13b7c1fa4aa27274efab13ff1c2828815;hpb=86e8b1ff3e831b09fabd498b76a78098f240b673;p=plomtask diff --git a/plomtask/db.py b/plomtask/db.py index 054060e..3917ce0 100644 --- a/plomtask/db.py +++ b/plomtask/db.py @@ -369,8 +369,14 @@ class BaseModel(Generic[BaseModelId]): # pylint: disable=unused-argument db_conn: DatabaseConnection, row: Row | list[Any]) -> BaseModelInstance: - """Make from DB row, update DB cache with it.""" + """Make from DB row (sans relations), update DB cache with it.""" obj = cls(*row) + assert obj.id_ is not None + for attr_name in cls.to_save_versioned: + attr = getattr(obj, attr_name) + table_name = attr.table_name + for row_ in db_conn.row_where(table_name, 'parent', obj.id_): + attr.history_from_row(row_) obj._cache() return obj