From b5a8051c6131c0c7bdb1f25c8f7e5c5a49f3039c Mon Sep 17 00:00:00 2001 From: wqy Date: Sat, 3 Sep 2022 08:21:43 +0800 Subject: [PATCH] Fix operation tree bug --- api/operation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/operation.py b/api/operation.py index 6a5536c..f0bb301 100644 --- a/api/operation.py +++ b/api/operation.py @@ -12,10 +12,10 @@ def _update_current_operation(name: str, old_id: int, id: int) -> None: def _add_redo_undo(name: str, redo: str, undo: str) -> int: with conn[name].cursor(row_factory=dict_row) as cur: - cur.execute("select max(id) from operation") - parent = int(cur.fetchone()['max']) + parent = _get_current_operation(name) cur.execute(f"insert into operation (id, redo, undo, parent) values (default, '{redo}', '{undo}', {parent})") - return parent + 1 + cur.execute("select max(id) from operation") + return int(cur.fetchone()['max']) # execute curr undo def _query_undo(name: str, id: str) -> dict[str, str]: