self.is_done = is_done
self.day = day
self.children: list[Todo] = []
+ self.parents: list[Todo] = []
@classmethod
def from_table_row(cls, db_conn: DatabaseConnection, row: Row) -> Todo:
for row in db_conn.exec('SELECT child FROM todo_children '
'WHERE parent = ?', (id_,)):
todo.children += [cls.by_id(db_conn, row[0])]
+ for row in db_conn.exec('SELECT parent FROM todo_children '
+ 'WHERE child = ?', (id_,)):
+ todo.parents += [cls.by_id(db_conn, row[0])]
assert isinstance(todo, Todo)
return todo
raise BadFormatException('cannot adopt same child twice')
walk_steps(child)
self.children += [child]
+ child.parents += [self]
def save(self, db_conn: DatabaseConnection) -> None:
"""Write self and children to DB and its cache."""