Make use of utility decorate

This commit is contained in:
wqy
2022-09-17 09:29:05 +08:00
parent bb93a51817
commit ee39d96120
2 changed files with 3 additions and 5 deletions

View File

@@ -25,9 +25,8 @@ def delete_junction(name: str, id: str) -> ChangeSet:
return
elevation = row['elevation']
demand = 'NULL' if row['demand'] == None else row['demand']
pattern = 'NULL' if row['pattern'] == None else row['pattern']
pattern = f'"{pattern}"' if pattern != 'NULL' else pattern
demand = utility.decorate(row['demand'], 'float', True)
pattern = utility.decorate(row['pattern'], 'str', True)
sql = f"delete from junctions where id = '{id}';"
undo_sql = f'insert into junctions (id, elevation, demand, pattern) values ("{id}", {elevation}, {demand}, {pattern});'

View File

@@ -26,8 +26,7 @@ def delete_reservoir(name: str, id: str) -> ChangeSet:
return
head = row['head']
pattern = 'NULL' if row['pattern'] == None else row['pattern']
pattern = f'"{pattern}"' if pattern != 'NULL' else pattern
pattern = utility.decorate(row['pattern'], 'str', True)
sql = f"delete from reservoirs where id = '{id}';"
undo_sql = f'insert into reservoirs (id, head, pattern) values ("{id}", {head}, {pattern});'