Open joshtracy3 opened 2 months ago
Hi @joshtracy3 thank you for reporting this. It can definitely be handled better internally, but I tried running this and it worked:
graph.add_nodes_from([(1, {"labels": "First", "name": "Josh\\'s Laptop"}), 2, 3])
Let me know if it works for you. Btw. what are you working on?
@katarinasupe yes this works if you escape the apostrophe's. There also seems to be an issue if the name contains a backslash. I just updated the functions to_cypher_labels
and to_cypher_values
in nx_translator
to double quotes. Seems to work alright. I'm working on an entity linkage problem.
Feel free to open a PR @joshtracy3 😄 Thank you for letting me know what works. I hope Memgraph is performing well for your use case.
If you still haven't, join our Discord server or schedule an office hours call for more questions.
Memgraph version Which version did you use? 1.6.0
Environment Some information about the environment you are using Memgraph on: operating system, how do you connect, with or without docker, which driver etc.
Operating System: Darwin OS Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 OS Release: 23.6.0 OS Architecture: arm64 Full Platform Info: macOS-14.6.1-arm64-arm-64bit
Connecting with docker. Not sure about which driver
Describe the bug A clear and concise description of what the bug is. When a string attribute value on a node contains an apostrophe, the nx_translator().to_cypher_queries(G) will break. It seems to be because string values are enclosed by a single quote instead of double quotes.
To Reproduce Steps to reproduce the behavior:
from warnings import filterwarnings
filterwarnings("ignore")
memgraph = Memgraph("127.0.0.1", 7687) memgraph.drop_database() graph = nx.Graph() graph.add_nodes_from([(1, {"labels": "First", "name": "Josh's Laptop"}), 2, 3]) graph.add_edges_from([(1, 2, {"type": "EDGE_TYPE"}), (1, 3)])
nx_translator = NxTranslator() for query in nx_translator.to_cypher_queries(graph): memgraph.execute(query)