Skip to content

update rel cypher queries for migrated kind nodes #6433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 12, 2025
Prev Previous commit
Next Next commit
account for timestamp in simple relationship query
  • Loading branch information
ajtmccarty committed May 9, 2025
commit 5694b2d9b9618fe5c47d30540f30639afc59f96d
12 changes: 8 additions & 4 deletions backend/infrahub/core/query/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ def add_source_match_to_query(self, source_branch: Branch) -> None:
if source_branch.is_global or source_branch.is_default:
source_query_match = """
MATCH (s:Node { uuid: $source_id })
WHERE NOT exists((s)-[:IS_PART_OF {status: "deleted", branch: $source_branch}]->(:Root))
OPTIONAL MATCH (s)-[delete_edge:IS_PART_OF {status: "deleted", branch: $source_branch}]->(:Root)
WHERE delete_edge.from <= $at
WITH *, s WHERE delete_edge IS NULL
"""
self.params["source_branch"] = source_branch.name
source_filter, source_filter_params = source_branch.get_query_filter_path(
Expand All @@ -226,7 +228,7 @@ def add_source_match_to_query(self, source_branch: Branch) -> None:
ORDER BY r.from DESC
LIMIT 1
}
WITH s WHERE s_is_active = TRUE
WITH *, s WHERE s_is_active = TRUE
""" % {"source_filter": source_filter}
self.params.update(source_filter_params)
self.add_to_query(source_query_match)
Expand All @@ -236,7 +238,9 @@ def add_dest_match_to_query(self, destination_branch: Branch, destination_id: st
if destination_branch.is_global or destination_branch.is_default:
destination_query_match = """
MATCH (d:Node { uuid: $destination_id })
WHERE NOT exists((d)-[:IS_PART_OF {status: "deleted", branch: $destination_branch}]->(:Root))
OPTIONAL MATCH (d)-[delete_edge:IS_PART_OF {status: "deleted", branch: $destination_branch}]->(:Root)
WHERE delete_edge.from <= $at
WITH *, d WHERE delete_edge IS NULL
"""
self.params["destination_branch"] = destination_branch.name
else:
Expand All @@ -253,7 +257,7 @@ def add_dest_match_to_query(self, destination_branch: Branch, destination_id: st
ORDER BY r.from DESC
LIMIT 1
}
WITH s, d WHERE d_is_active = TRUE
WITH *, d WHERE d_is_active = TRUE
""" % {"destination_filter": destination_filter}
self.params.update(destination_filter_params)
self.add_to_query(destination_query_match)
Expand Down
Loading