From 7455fc25bb4fa263ef2896756b172590d970c433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=90=BC=E9=92=B0?= Date: Thu, 15 Sep 2022 13:55:50 +0800 Subject: [PATCH 1/3] fix coordinates sql --- api/s2_junctions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/s2_junctions.py b/api/s2_junctions.py index 6ba6a71..41a4398 100644 --- a/api/s2_junctions.py +++ b/api/s2_junctions.py @@ -40,7 +40,7 @@ def delete_junction(name: str, id: str) -> ChangeSet: pattern = 'NULL' if row['pattern'] == None else row['pattern'] pattern = f'"{pattern}"' if pattern != 'NULL' else pattern - cur.execute(f"select * from coordinates where id = '{id}'") + cur.execute(f"select * from coordinates where node = '{id}'") row = cur.fetchone() if row == None: return From b3bb99b18f79902a526246228d32b30ddcb947d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=90=BC=E9=92=B0?= Date: Thu, 15 Sep 2022 14:06:31 +0800 Subject: [PATCH 2/3] Junction type is fixed enum value --- api/s2_junctions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/s2_junctions.py b/api/s2_junctions.py index 41a4398..b639d62 100644 --- a/api/s2_junctions.py +++ b/api/s2_junctions.py @@ -53,7 +53,7 @@ def delete_junction(name: str, id: str) -> ChangeSet: cur.execute(sql) redo = sql.replace("'", '"') - undo = f'insert into _node (id, type) values ("{id}", "{type}");' + undo = f'insert into _node (id, type) values ("{id}", "JUNCTION");' undo += f" insert into junctions (id, elevation, demand, pattern) values ('{id}', {elevation}, {demand}, {pattern});" undo += f" insert into coordinates (node, coord) values ('{id}', '{coord}');" add_operation(name, redo, undo) From bb859bb946ccc82210a214da0aa0e8a015f09cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=90=BC=E9=92=B0?= Date: Thu, 15 Sep 2022 14:10:26 +0800 Subject: [PATCH 3/3] Fix delete_junction undo sql --- api/s2_junctions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/s2_junctions.py b/api/s2_junctions.py index b639d62..a4a37db 100644 --- a/api/s2_junctions.py +++ b/api/s2_junctions.py @@ -54,8 +54,8 @@ def delete_junction(name: str, id: str) -> ChangeSet: redo = sql.replace("'", '"') undo = f'insert into _node (id, type) values ("{id}", "JUNCTION");' - undo += f" insert into junctions (id, elevation, demand, pattern) values ('{id}', {elevation}, {demand}, {pattern});" - undo += f" insert into coordinates (node, coord) values ('{id}', '{coord}');" + undo += f' insert into junctions (id, elevation, demand, pattern) values ("{id}", {elevation}, {demand}, {pattern});' + undo += f' insert into coordinates (node, coord) values ("{id}", "{coord}");' add_operation(name, redo, undo) change = ChangeSet()