latest
This commit is contained in:
@@ -70,11 +70,10 @@ class BaseNode(CommonModel): # pyre-ignore[13]
|
||||
|
||||
def merge(self, database: str = 'neo4j') -> None:
|
||||
"""Merge this node into the graph."""
|
||||
|
||||
|
||||
params = self._get_merge_parameters()
|
||||
|
||||
all_labels = [self.__primarylabel__] + self.__secondarylabels__
|
||||
|
||||
|
||||
cypher = f"""
|
||||
MERGE (n:{":".join(all_labels)} {{ {self.__primaryproperty__}: $pp }})
|
||||
ON MATCH SET n += $set_on_match
|
||||
@@ -82,10 +81,15 @@ class BaseNode(CommonModel): # pyre-ignore[13]
|
||||
SET n += $always_set
|
||||
RETURN n
|
||||
"""
|
||||
|
||||
|
||||
print(f"DEBUG: Executing merge query: {cypher}")
|
||||
print(f"DEBUG: With params: {params}")
|
||||
print(f"DEBUG: Database: {database}")
|
||||
|
||||
graph = GraphConnection()
|
||||
with graph.driver.session(database=database) as session:
|
||||
result = session.run(cypher, params).single()
|
||||
print(f"DEBUG: Merge result: {result}")
|
||||
if result:
|
||||
return self.__class__(**dict(result["n"]))
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user