Skip to content

Commit 0783099

Browse files
committed
Additional clean of CYPHER query
1 parent fb541fc commit 0783099

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

backend/infrahub/core/migrations/query/node_duplicate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,10 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: dict[str, Any]) -> No
184184
%(sub_query_in)s
185185
}
186186
WITH p2 as peer_node, rel_inband, active_node, new_node
187-
FOREACH (i in CASE WHEN rel_inband.branch = "-global-" or rel_inband.branch = $branch THEN [1] ELSE [] END |
187+
FOREACH (i in CASE WHEN rel_inband.branch IN ["-global-", $branch] THEN [1] ELSE [] END |
188188
SET rel_inband.to = $current_time
189189
)
190190
191-
WITH peer_node, rel_inband, active_node, new_node
192191
RETURN DISTINCT new_node
193192
""" % {
194193
"branch_filter": branch_filter,

backend/infrahub/core/migrations/schema/node_remove.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ def render_node_remove_query(self, branch_filter: str) -> str:
105105
LIMIT 1
106106
}
107107
WITH n1 as active_node, rel_inband1 as rel_inband, p1 as peer_node
108-
WHERE rel_inband.status = "active" AND rel_inband.to IS NULL
108+
WHERE rel_inband.status = "active"
109109
CALL {
110110
%(sub_query)s
111111
}
112112
WITH p2 as peer_node, rel_inband, active_node
113-
FOREACH (i in CASE WHEN rel_inband.branch = "-global-" or rel_inband.branch = $branch THEN [1] ELSE [] END |
113+
FOREACH (i in CASE WHEN rel_inband.branch IN ["-global-", $branch] THEN [1] ELSE [] END |
114114
SET rel_inband.to = $current_time
115115
)
116116
""" % {"sub_query": sub_query, "branch_filter": branch_filter}
@@ -151,7 +151,7 @@ def render_node_remove_query(self, branch_filter: str) -> str:
151151
LIMIT 1
152152
}
153153
WITH n1 as active_node, rel_outband1 as rel_outband, p1 as peer_node
154-
WHERE rel_outband.status = "active" AND rel_outband.to IS NULL
154+
WHERE rel_outband.status = "active"
155155
CALL {
156156
%(sub_query)s
157157
}

0 commit comments

Comments
 (0)