atharrva01 commented on code in PR #383:
URL: https://github.com/apache/hugegraph-ai/pull/383#discussion_r4283640546
##########
hugegraph-llm/src/hugegraph_llm/nodes/hugegraph_node/graph_query_node.py:
##########
@@ -355,7 +356,7 @@ def _subgraph_query(self, context: Dict[str, Any]) ->
Dict[str, Any]:
if not matched_vids:
return context
- gremlin_query = VERTEX_QUERY_TPL.format(keywords=matched_vids)
+ gremlin_query =
VERTEX_QUERY_TPL.format(keywords=",".join(gremlin_str_literal(vid) for vid in
matched_vids))
Review Comment:
You're right, the vertex query used to keep these numeric and my change
broke that. Fixed in fbd4743: ints now go out as plain numbers (`g.V(123)`),
only strings get quoted. Added a test for a numeric id too.
##########
hugegraph-llm/src/hugegraph_llm/utils/hugegraph_utils.py:
##########
@@ -34,6 +34,11 @@
BACKUP_DIR = str(os.path.join(resource_path, "backup-graph-data-4020",
huge_settings.graph_name))
+def gremlin_str_literal(value) -> str:
+ """Quote a value as a Groovy single-quoted string literal (no `$`
interpolation), e.g. 1:O'Brien -> '1:O\\'Brien'."""
+ return "'" + str(value).replace("\\", "\\\\").replace("'", "\\'") + "'"
Review Comment:
Fixed in fbd4743. Newline, CR, tab, \b and \f now get escaped, and any other
control char goes out as \uXXXX. Added tests for these, including one that
checks the escaped string decodes back to the original.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]