home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve consistency of DB column names.
[plomtask]
/
plomtask
/
conditions.py
diff --git
a/plomtask/conditions.py
b/plomtask/conditions.py
index 27ab62cf303084f4ae62add99ac4f6d39616d4f0..98a0b99e667adfe11f9f4f0ef3439df03a6cc67f 100644
(file)
--- a/
plomtask/conditions.py
+++ b/
plomtask/conditions.py
@@
-1,5
+1,6
@@
"""Non-doable elements of ProcessStep/Todo chains."""
from __future__ import annotations
"""Non-doable elements of ProcessStep/Todo chains."""
from __future__ import annotations
+from typing import Any
from sqlite3 import Row
from plomtask.db import DatabaseConnection, BaseModel
from plomtask.misc import VersionedAttribute
from sqlite3 import Row
from plomtask.db import DatabaseConnection, BaseModel
from plomtask.misc import VersionedAttribute
@@
-20,15
+21,18
@@
class Condition(BaseModel):
@classmethod
def from_table_row(cls, db_conn: DatabaseConnection,
@classmethod
def from_table_row(cls, db_conn: DatabaseConnection,
- row: Row) -> Condition:
+ row: Row
| list[Any]
) -> Condition:
"""Build condition from row, including VersionedAttributes."""
"""Build condition from row, including VersionedAttributes."""
- condition = cls(row[0], row[1])
+ condition = super().from_table_row(db_conn, row)
+ assert isinstance(condition, Condition)
for title_row in db_conn.exec('SELECT * FROM condition_titles '
for title_row in db_conn.exec('SELECT * FROM condition_titles '
- 'WHERE parent_id = ?', (row[0],)):
- condition.title.history[title_row[1]] = title_row[2]
+ 'WHERE parent = ?', (row[0],)):
+ condition.title.history[title_row[1]]\
+ = title_row[2] # pylint: disable=no-member
for desc_row in db_conn.exec('SELECT * FROM condition_descriptions '
for desc_row in db_conn.exec('SELECT * FROM condition_descriptions '
- 'WHERE parent_id = ?', (row[0],)):
- condition.description.history[desc_row[1]] = desc_row[2]
+ 'WHERE parent = ?', (row[0],)):
+ condition.description.history[desc_row[1]]\
+ = desc_row[2] # pylint: disable=no-member
return condition
@classmethod
return condition
@classmethod
@@
-49,17
+53,14
@@
class Condition(BaseModel):
create: bool = False) -> Condition:
"""Collect (or create) Condition and its VersionedAttributes."""
condition = None
create: bool = False) -> Condition:
"""Collect (or create) Condition and its VersionedAttributes."""
condition = None
- if id_ in db_conn.cached_conditions.keys():
- condition = db_conn.cached_conditions[id_]
- else:
- for row in db_conn.exec('SELECT * FROM conditions WHERE id = ?',
- (id_,)):
- condition = cls.from_table_row(db_conn, row)
- break
+ if id_:
+ condition, _ = super()._by_id(db_conn, id_)
if not condition:
if not create:
raise NotFoundException(f'Condition not found of id: {id_}')
condition = cls(id_, False)
if not condition:
if not create:
raise NotFoundException(f'Condition not found of id: {id_}')
condition = cls(id_, False)
+ condition.save(db_conn)
+ assert isinstance(condition, Condition)
return condition
def save(self, db_conn: DatabaseConnection) -> None:
return condition
def save(self, db_conn: DatabaseConnection) -> None: