Skip to content
Merged
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion graphrag_sdk/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ def to_graph_query(self) -> str:
[str(attr) for attr in self.attributes if not attr.unique]
)
if self.description:
non_unique_attributes += f"{', ' if len(non_unique_attributes) > 0 else ''} {descriptionKey}: '{self.description}'"
# Escape special characters to prevent Cypher syntax errors
escaped_description = self.description.replace("\\", "\\\\").replace("'", "\\'").replace('"', '\\"')
non_unique_attributes += f"{', ' if len(non_unique_attributes) > 0 else ''} {descriptionKey}: '{escaped_description}'"
return f"MERGE (n:{self.label} {{{unique_attributes}}}) SET n += {{{non_unique_attributes}}} RETURN n"

def __str__(self) -> str:
Expand Down