Support to unset
This commit is contained in:
@@ -52,7 +52,8 @@ def set_status(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
new = Status(raw_new)
|
||||
|
||||
redo_sql = f"delete from status where link = {new.f_link};"
|
||||
redo_sql += f"\ninsert into status (link, status, setting) values ({new.f_link}, {new.f_status}, {new.f_setting});"
|
||||
if new.status != None or new.setting != None:
|
||||
redo_sql += f"\ninsert into status (link, status, setting) values ({new.f_link}, {new.f_status}, {new.f_setting});"
|
||||
|
||||
undo_sql = f"delete from status where link = {old.f_link};"
|
||||
if old.status != None or old.setting != None:
|
||||
|
||||
@@ -26,7 +26,8 @@ def set_pattern(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
# TODO: transaction ?
|
||||
redo_sql = f"delete from patterns where id = {f_id};"
|
||||
redo_sql += f"\ndelete from _pattern where id = {f_id};"
|
||||
redo_sql += f"\ninsert into _pattern (id) values ({f_id});"
|
||||
if len(cs.operations[0]['factors']) > 0:
|
||||
redo_sql += f"\ninsert into _pattern (id) values ({f_id});"
|
||||
for factor in cs.operations[0]['factors']:
|
||||
f_factor = float(factor)
|
||||
redo_sql += f"\ninsert into patterns (id, factor) values ({f_id}, {f_factor});"
|
||||
@@ -34,7 +35,8 @@ def set_pattern(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
undo_sql = f"delete from patterns where id = {f_id};"
|
||||
undo_sql += f"\ndelete from _pattern where id = {f_id};"
|
||||
undo_sql += f"\ninsert into _pattern (id) values ({f_id});"
|
||||
if len(old['factors']) > 0:
|
||||
undo_sql += f"\ninsert into _pattern (id) values ({f_id});"
|
||||
for f_factor in old['factors']:
|
||||
undo_sql += f"\ninsert into patterns (id, factor) values ({f_id}, {f_factor});"
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ def set_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
# TODO: transaction ?
|
||||
redo_sql = f"delete from curves where id = {f_id};"
|
||||
redo_sql += f"\ndelete from _curve where id = {f_id};"
|
||||
redo_sql += f"\ninsert into _curve (id) values ({f_id});"
|
||||
if len(cs.operations[0]['coords']) > 0:
|
||||
redo_sql += f"\ninsert into _curve (id) values ({f_id});"
|
||||
for xy in cs.operations[0]['coords']:
|
||||
x, y = float(xy['x']), float(xy['y'])
|
||||
f_x, f_y = x, y
|
||||
@@ -37,7 +38,8 @@ def set_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
undo_sql = f"delete from curves where id = {f_id};"
|
||||
undo_sql += f"\ndelete from _curve where id = {f_id};"
|
||||
undo_sql += f"\ninsert into _curve (id) values ({f_id});"
|
||||
if len(old['coords']) > 0:
|
||||
undo_sql += f"\ninsert into _curve (id) values ({f_id});"
|
||||
for xy in old['coords']:
|
||||
f_x, f_y = xy['x'], xy['y']
|
||||
undo_sql += f"\ninsert into curves (id, x, y) values ({f_id}, {f_x}, {f_y});"
|
||||
|
||||
Reference in New Issue
Block a user