Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
community: Apache AGE wrapper. Ensure Node Uniqueness by ID. (#28759)
**Description:** The Apache AGE graph integration incorrectly handled node merging, allowing duplicate nodes with different IDs but the same type and other properties. Unlike [Neo4j](https://github.com/langchain-ai/langchain/blob/cdf62021569dd7f02b35679b46ee6abe92f02cb7/libs/community/langchain_community/graphs/neo4j_graph.py#L47), [Memgraph](https://github.com/langchain-ai/langchain/blob/cdf62021569dd7f02b35679b46ee6abe92f02cb7/libs/community/langchain_community/graphs/memgraph_graph.py#L50), [Kuzu](https://github.com/langchain-ai/langchain/blob/cdf62021569dd7f02b35679b46ee6abe92f02cb7/libs/community/langchain_community/graphs/kuzu_graph.py#L253), and [Gremlin](https://github.com/langchain-ai/langchain/blob/cdf62021569dd7f02b35679b46ee6abe92f02cb7/libs/community/langchain_community/graphs/gremlin_graph.py#L165), it did not use the node ID as the primary identifier for merging. This inconsistency caused data integrity issues and unexpected behavior when users expected updates to specific nodes by ID. **Solution:** This PR modifies the `node_insert_query` to `MERGE` nodes based on label and ID *only* and updates properties with `SET`, aligning the behavior with other graph database integrations. The `_format_properties` method was also modified to handle id overrides. **Impact:** This fix ensures data integrity by preventing duplicate nodes, and provides a consistent behavior across graph database integrations.
- Loading branch information