Workaround to prevent pump (cascade) deletion...

This commit is contained in:
WQY\qiong
2023-02-04 16:25:14 +08:00
parent 133ba32cdf
commit ae793d8ab5

View File

@@ -175,9 +175,12 @@ def inp_out_pump(name: str) -> list[str]:
def unset_pump_by_curve(name: str, curve: str) -> ChangeSet:
cs = ChangeSet()
rows = read_all(name, f"select id from pumps where head = '{curve}'")
rows = read_all(name, f"select * from pumps where head = '{curve}'")
for row in rows:
cs.append(g_update_prefix | {'type': 'pump', 'id': row['id'], 'head': None})
if row['power'] != None:
cs.append(g_update_prefix | {'type': 'pump', 'id': row['id'], 'head': None})
else: # workaround to prevent pump deletion... and I don't want to remove constraint...
cs.append(g_update_prefix | {'type': 'pump', 'id': row['id'], 'head': None, 'power': 0.0})
return cs