0

In my go application, I'm trying to execute a MERGE query, using the golang-neo4j-bolt-driver.

The interface of the ExecNeo and ExecPipeline requires a string map with interface object as a parameter. When executing the query, I get the error message that a literal map is required:

Internal Error(messages.FailureMessage): messages.FailureMessage{Metadata:map[string]interface {}{"code":"Neo.ClientError.Statement.SyntaxError", "message":"Parameter maps cannot be used in MERGE patterns (use a literal map instead`).

Does anyone have an example of creating an literal map?

rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38
  • 1
    This is a Neo4j error, it's not referring to Go maps. A search for "Parameter maps cannot be used in MERGE patterns" turns up many cases of this error in various client languages. – Adrian Feb 16 '18 at 16:40
  • 5
    Possible duplicate of [Create is working but MERGE in neo4j post params has error](https://stackoverflow.com/questions/28714278/create-is-working-but-merge-in-neo4j-post-params-has-error) – Adrian Feb 16 '18 at 16:40
  • Can you share your code that execute the query to see how you create the query parameters ? – logisima Feb 17 '18 at 10:04

1 Answers1

0

Thanks everyone for pointing me in the right direction. Here's a piece of sample code that 'works on my machine':

func TestMergeWithLiteralMap(t *testing.T) {
d := bolt.NewDriver()

conn, err := d.OpenNeo("bolt://neo4j:admin@127.0.0.1:7687")
if err != nil {
    panic(err)
}
defer conn.Close()

qry := `MATCH (f:Node1 {Name: {f_name}, Group: {f_group} }), 
              (t:Node2{Name: {t_name}, Group: {t_group} })
        WITH f,t 
        MERGE (t) <- [:NREL] - (f)`
params := map[string]interface{}{"f_name": "apple", "f_group": "public", "t_name": "pear", "t_group": "private"}
stmt, err := conn.PrepareNeo(qry)
if err != nil {
    panic(err)
}
results, err := stmt.ExecNeo(params)
if err != nil {
    panic(err)
}
glog.Errorf("Executed statement: %s\nWith values: %s\n", stmt, params)

numResult, _ := results.RowsAffected()
metadata := results.Metadata()
glog.Errorf("[NEO-CLIENT] Graphed %s '%s (%s)', CREATED ROWS: %d\n", metadata["kind"], metadata["name"], metadata["namespace"], numResult)

err = stmt.Close()
if err != nil {
    panic(err)
}

}