Refine api to support one batch command

This commit is contained in:
WQY\qiong
2022-10-26 19:35:04 +08:00
parent 78d7be1d9a
commit 65e2ce2541
16 changed files with 182 additions and 178 deletions

View File

@@ -67,7 +67,7 @@ def get_option(name: str) -> dict[str, Any]:
return d
def set_option(name: str, cs: ChangeSet) -> ChangeSet:
def set_option_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
raw_old = get_option(name)
old = {}
@@ -98,4 +98,8 @@ def set_option(name: str, cs: ChangeSet) -> ChangeSet:
undo_sql += f"update options set value = '{value}' where key = '{key}';"
undo_cs |= { key: value }
return execute_command(name, redo_sql, undo_sql, redo_cs, undo_cs)
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
def set_option(name: str, cs: ChangeSet) -> ChangeSet:
return execute_command(name, set_option_cache(name, cs))