cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Pause, resolving how to handle anonymous content

Python neo4j

bjwiley23
Node

Hi,
I am running this code and the first parameter is getting passed but the number in the reursive depth $n gives the error:
CypherSyntaxError: {code: Neo.ClientError.Statement.SyntaxError} {message: Parameter maps cannot be used in MATCH patterns (use a literal map instead, eg. "{id: {param}.id}")

Here is my code. If I put any number like 2 instead of $n it works:

params = {"prot": 'C', "n": 2}
    with session.begin_transaction() as tx:
        result = tx.run("MATCH p = (n:Protein { name:$prot })<-[:REGULATES*1..$n]->(b:Protein) \
                     WITH *, relationships(p) AS rs \
                     RETURN \
                         startNode(last(rs)).name AS Protein1, \
                         last(rs).direction AS Regulates, \
                         endNode(last(rs)).name AS Protein2, \
                         length(p) AS pathLength",
                    params)
1 REPLY 1

steve_ellebrach
Node Link

I'm not at my computer with neo4j, but have you tried renaming either your 'n' parameter or the 'n' variable in your first Protein node? Using the same name in both places might be confusing Cypher.