Make use of change set
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
from psycopg.rows import dict_row
|
||||
from .operation import *
|
||||
from .connection import g_conn_dict as conn
|
||||
from .change_set import ChangeSet
|
||||
|
||||
def get_title(name: str) -> str:
|
||||
with conn[name].cursor(row_factory=dict_row) as cur:
|
||||
cur.execute(f"select * from title")
|
||||
return cur.fetchone()['value']
|
||||
|
||||
def set_title(name: str, value: str) -> None:
|
||||
def set_title(name: str, value: str) -> ChangeSet:
|
||||
old = get_title(name)
|
||||
|
||||
with conn[name].cursor() as cur:
|
||||
@@ -17,3 +18,7 @@ def set_title(name: str, value: str) -> None:
|
||||
redo = sql.replace("'", '"')
|
||||
undo = f'update title set value = "{old}"'
|
||||
add_operation(name, redo, undo)
|
||||
|
||||
change = ChangeSet()
|
||||
change.update('title', 'null', 'value')
|
||||
return change
|
||||
|
||||
Reference in New Issue
Block a user