Code refactor for change set
This commit is contained in:
@@ -26,7 +26,7 @@ def get_curve(name: str, id: str) -> dict[str, Any]:
|
||||
return d
|
||||
|
||||
|
||||
def set_curve_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
def set_curve_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
id = cs.operations[0]['id']
|
||||
f_id = f"'{id}'"
|
||||
|
||||
@@ -60,14 +60,14 @@ def set_curve_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
redo_cs = g_update_prefix | { 'type': 'curve' } | new
|
||||
undo_cs = g_update_prefix | { 'type': 'curve' } | old
|
||||
|
||||
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
return DbChangeSet(redo_sql, undo_sql, [redo_cs], [undo_cs])
|
||||
|
||||
|
||||
def set_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_curve_cache(name, cs))
|
||||
|
||||
|
||||
def add_curve_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
def add_curve_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
id = cs.operations[0]['id']
|
||||
f_id = f"'{id}'"
|
||||
|
||||
@@ -88,14 +88,14 @@ def add_curve_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
redo_cs = g_add_prefix | { 'type': 'curve' } | new
|
||||
undo_cs = g_delete_prefix | { 'type': 'curve' } | { 'id' : id }
|
||||
|
||||
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
return DbChangeSet(redo_sql, undo_sql, [redo_cs], [undo_cs])
|
||||
|
||||
|
||||
def add_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, add_curve_cache(name, cs))
|
||||
|
||||
|
||||
def delete_curve_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
def delete_curve_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
id = cs.operations[0]['id']
|
||||
f_id = f"'{id}'"
|
||||
|
||||
@@ -114,7 +114,7 @@ def delete_curve_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
redo_cs = g_delete_prefix | { 'type': 'curve' } | { 'id' : id }
|
||||
undo_cs = g_add_prefix | { 'type': 'curve' } | old
|
||||
|
||||
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
return DbChangeSet(redo_sql, undo_sql, [redo_cs], [undo_cs])
|
||||
|
||||
|
||||
def delete_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
Reference in New Issue
Block a user