Skip to content

Commit 6677ed5

Browse files
authored
Merge branch 'main' into dependabot/pip/ipykernel-7.1.0
2 parents d27f92d + 3a0aa5a commit 6677ed5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

graphrag_sdk/entity.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ def to_graph_query(self) -> str:
144144
[str(attr) for attr in self.attributes if not attr.unique]
145145
)
146146
if self.description:
147-
non_unique_attributes += f"{', ' if len(non_unique_attributes) > 0 else ''} {descriptionKey}: '{self.description}'"
147+
# Escape special characters to prevent Cypher syntax errors
148+
escaped_description = self.description.replace("\\", "\\\\").replace("'", "\\'").replace('"', '\\"')
149+
non_unique_attributes += f"{', ' if len(non_unique_attributes) > 0 else ''} {descriptionKey}: '{escaped_description}'"
148150
return f"MERGE (n:{self.label} {{{unique_attributes}}}) SET n += {{{non_unique_attributes}}} RETURN n"
149151

150152
def __str__(self) -> str:

0 commit comments

Comments
 (0)