Removed redundant entity_id extraction in upsert logic for Neo4JStorage
This commit is contained in:
@@ -517,7 +517,6 @@ class Neo4JStorage(BaseGraphStorage):
|
|||||||
"""
|
"""
|
||||||
properties = node_data
|
properties = node_data
|
||||||
entity_type = properties["entity_type"]
|
entity_type = properties["entity_type"]
|
||||||
entity_id = properties["entity_id"]
|
|
||||||
if "entity_id" not in properties:
|
if "entity_id" not in properties:
|
||||||
raise ValueError("Neo4j: node properties must contain an 'entity_id' field")
|
raise ValueError("Neo4j: node properties must contain an 'entity_id' field")
|
||||||
|
|
||||||
@@ -527,15 +526,15 @@ class Neo4JStorage(BaseGraphStorage):
|
|||||||
async def execute_upsert(tx: AsyncManagedTransaction):
|
async def execute_upsert(tx: AsyncManagedTransaction):
|
||||||
query = (
|
query = (
|
||||||
"""
|
"""
|
||||||
MERGE (n:base {entity_id: $properties.entity_id})
|
MERGE (n:base {entity_id: $entity_id})
|
||||||
SET n += $properties
|
SET n += $properties
|
||||||
SET n:`%s`
|
SET n:`%s`
|
||||||
"""
|
"""
|
||||||
% entity_type
|
% entity_type
|
||||||
)
|
)
|
||||||
result = await tx.run(query, properties=properties)
|
result = await tx.run(query, entity_id=node_id, properties=properties)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"Upserted node with entity_id '{entity_id}' and properties: {properties}"
|
f"Upserted node with entity_id '{node_id}' and properties: {properties}"
|
||||||
)
|
)
|
||||||
await result.consume() # Ensure result is fully consumed
|
await result.consume() # Ensure result is fully consumed
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user