Support batch operation table
This commit is contained in:
@@ -113,6 +113,8 @@ def get_current_operation(name: str) -> int:
|
||||
|
||||
|
||||
def execute_command(name: str, command: DbChangeSet) -> ChangeSet:
|
||||
op_table = read(name, "select * from operation_table")['option']
|
||||
|
||||
write(name, command.redo_sql)
|
||||
|
||||
parent = get_current_operation(name)
|
||||
@@ -120,10 +122,11 @@ def execute_command(name: str, command: DbChangeSet) -> ChangeSet:
|
||||
undo_sql = command.undo_sql.replace("'", "''")
|
||||
redo_cs_str = str(command.redo_cs).replace("'", "''")
|
||||
undo_cs_str = str(command.undo_cs).replace("'", "''")
|
||||
write(name, f"insert into operation (id, redo, undo, parent, redo_cs, undo_cs) values (default, '{redo_sql}', '{undo_sql}', {parent}, '{redo_cs_str}', '{undo_cs_str}')")
|
||||
write(name, f"insert into {op_table} (id, redo, undo, parent, redo_cs, undo_cs) values (default, '{redo_sql}', '{undo_sql}', {parent}, '{redo_cs_str}', '{undo_cs_str}')")
|
||||
|
||||
current = read(name, 'select max(id) as id from operation')['id']
|
||||
write(name, f"update current_operation set id = {current}")
|
||||
if op_table == 'operation':
|
||||
current = read(name, 'select max(id) as id from operation')['id']
|
||||
write(name, f"update current_operation set id = {current}")
|
||||
|
||||
return ChangeSet.from_list(command.redo_cs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user