From ae793d8ab590a45df2f499644dcb5b10d214392e Mon Sep 17 00:00:00 2001 From: "WQY\\qiong" Date: Sat, 4 Feb 2023 16:25:14 +0800 Subject: [PATCH] Workaround to prevent pump (cascade) deletion... --- api/s6_pumps.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/s6_pumps.py b/api/s6_pumps.py index 1f9dce8..1bdbef9 100644 --- a/api/s6_pumps.py +++ b/api/s6_pumps.py @@ -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