home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactor BaseModel.from_table_row in regards to VersionedAttributes.
[plomtask]
/
plomtask
/
db.py
diff --git
a/plomtask/db.py
b/plomtask/db.py
index 054060e13b7c1fa4aa27274efab13ff1c2828815..3917ce0558e3f7deb1f917a07eb5dd4df7b279e6 100644
(file)
--- 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:
# 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)
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
obj._cache()
return obj