Fix node_degree error for PostgreSQL graph storage

This commit is contained in:
yangdx
2025-04-04 03:40:17 +08:00
parent 689cf44a5d
commit 0947feff2d

View File

@@ -1232,13 +1232,15 @@ class PGGraphStorage(BaseGraphStorage):
label = node_id.strip('"')
query = """SELECT * FROM cypher('%s', $$
MATCH (n:base {entity_id: "%s"})-[]->(x)
MATCH (n:base {entity_id: "%s"})-[]-(x)
RETURN count(x) AS total_edge_count
$$) AS (total_edge_count integer)""" % (self.graph_name, label)
record = (await self._query(query))[0]
if record:
edge_count = int(record["total_edge_count"])
print(f"edge_count: {edge_count} / {node_id}")
return edge_count
async def edge_degree(self, src_id: str, tgt_id: str) -> int: