Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-09-2020 10:54 AM
I want to call apoc procedure from the golang driver. I can fire basic cypher queries from driver but while call apoc procedure it throws syntax error.
panic: An error occurred getting result of exec command: messages.FailureMessage{Metadata:map[string]interface {}{"code":"Neo.ClientError.Statement.SyntaxError", "message":"Invalid input '3': expected whitespace, '.', node labels, '[', \"=~\", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', '~', \"<>\", \"!=\", '<', '>', \"<=\", \">=\", AND, XOR, OR, ',' or ')' (line 1, column 74 (offset: 73))\n\"call apoc.export.json.query(\"MATCH t = (p)-[:has*0..] -> (i:node{`name`:\"39\"}) return p;\",\"2.json\")\"\n
04-09-2020 04:10 PM
Are you sure backticks around name
is the right way to escape within apoc for golang? Seems like The error message is pointing toward that.
04-09-2020 11:37 PM
Thank you @terryfranklin82. I tried removing backticks and still, I am getting the same error.
call apoc.export.json.query("MATCH t = (p)-[:has*0..] -> (i:node{name:"39"}) return p;","1.json")
I want to fire the above query from golang. Basically, golang wants me to pass the query as a string. Here the query itself contains a nested string in it. I think the error is due to that. Below is the syntax I am using to query from golang.
conn.PrepareNeo("call apoc.export.json.query(\"MATCH t = (p)-[:has*0..] -> (i:node{name:\"39\"}) return p;\",\"1.json\"")
04-09-2020 11:55 PM
What about removing the whitespace in your match spec
->
does that help?
04-10-2020 12:01 AM
@terryfranklin82. Thanks for reviewing.
I removed the whitespaces but that fails.
Updated query from golang.
stmt, err := conn.PrepareNeo("call apoc.export.json.query(\"MATCH t=(p)-[:has*0..]->(i:node{name:\"39\"})return p;\",\"1.json\")")
Output when I print the stmt.
&{[] call apoc.export.json.query("MATCH t=(p)-[:has*0..]->(i:node{name:"39"})return p;","1.json") 0xc0000a6000 false <nil>}
The error which I am getting now.
panic: Neo4J reported a failure for the query
Internal Error(messages.FailureMessage):messages.FailureMessage{Metadata:map[string]interface {}{"code":"Neo.ClientError.Statement.SyntaxError", "message":"Invalid input '3': expected whitespace, '.', node labels, '[', \"=~\", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', '~', \"<>\", \"!=\", '<', '>', \"<=\", \">=\", AND, XOR, OR, ',' or ')' (line 1, column 68 (offset: 67))\n\"call apoc.export.json.query(\"MATCH t=(p)-[:has*0..]->(i:node{name:\"39\"})return p;\",\"1.json\")\"\n
04-10-2020 12:37 AM
Maybe try with the relationship whitespace removed and the backticks added in again?
It's definitely a syntax error of some kind. Escaping cypher within a function call can be a bit tricky to begin with, but once you get the pattern it's easier to follow.
All the sessions of the conference are now available online