Skip to content
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

community: Apache AGE wrapper. Ensure Node Uniqueness by ID. #28759

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libs/community/langchain_community/graphs/age_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,9 @@ def add_graph_documents(
# query for inserting nodes
node_insert_query = (
"""
MERGE (n:`{label}` {properties})
"""
MERGE (n:`{label}` {{`id`: "{id}"}})
SET n = {properties}
"""
if not include_source
else """
MERGE (n:`{label}` {properties})
Expand Down Expand Up @@ -735,6 +736,7 @@ def add_graph_documents(
query = node_insert_query.format(
label=AGEGraph.clean_graph_labels(node.type),
properties=self._format_properties(node.properties),
id=node.id,
)

self.query(query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

test_data = [
GraphDocument(
nodes=[Node(id="foo", type="foo"), Node(id="bar", type="bar")],
nodes=[
Node(id="foo", type="foo"),
Node(id="bar", type="bar"),
Node(id="foo", type="foo", properties={"property_a": "a"}),
],
relationships=[
Relationship(
source=Node(id="foo", type="foo"),
Expand Down
Loading