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

@@ -14,7 +14,7 @@ def get_pattern(name: str, id: str) -> dict[str, Any]:
return { 'id': id, 'factors': ps }
def set_pattern(name: str, cs: ChangeSet) -> ChangeSet:
def set_pattern_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
id = cs.operations[0]['id']
old = get_pattern(name, id)
@@ -42,4 +42,8 @@ def set_pattern(name: str, cs: ChangeSet) -> ChangeSet:
redo_cs = g_update_prefix | { 'type': 'pattern' } | new
undo_cs = g_update_prefix | { 'type': 'pattern' } | old
return execute_command(name, redo_sql, undo_sql, redo_cs, undo_cs)
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
def set_pattern(name: str, cs: ChangeSet) -> ChangeSet:
return execute_command(name, set_pattern_cache(name, cs))