thingdom / node-neo4j

[RETIRED] Neo4j graph database driver (REST API client) for Node.js
Apache License 2.0
925 stars 135 forks source link

Library cannot handle Labels passed as parameter to query #192

Closed mohummedalee closed 8 years ago

mohummedalee commented 8 years ago

While queries like

db.cypher({
        query: "MATCH (n:User) WHERE n._id = {given} RETURN n",
        params: {given: 'xxx'}
    },
    callback
};

work completely fine, queries of the form:

db.cypher({
        query: "MATCH (n:{type}) WHERE n._id = {given} RETURN n",
        params: {given: 'xxx', type: 'User'}
    },
    callback
};

where the label is passed as a parameter, report a syntax error. This is a basic functionality and should exist.

aseemk commented 8 years ago

This is a limitation (by design) of Cypher the language, not this library.

Parameters can not be used as for property names, relationship types and labels, since these patterns are part of the query structure that is compiled into a query plan.

http://neo4j.com/docs/stable/cypher-parameters.html

In general, this library does not do anything with your query or parameters, so any errors you get back relating to your query are coming from Neo4j, not this library.

Hope this helps!