versae / neo4j-rest-client

Object-oriented Python library to interact with Neo4j standalone REST server
http://neo4j-rest-client.rtfd.org
GNU General Public License v3.0
264 stars 73 forks source link

Create doesn't work with lists #130

Open Yorkst opened 8 years ago

Yorkst commented 8 years ago

db.nodes.create(parameter=[]) fails with "Bad Request. Bad request syntax or unsupported method."

versae commented 8 years ago

That's because the REST API doesn't support storing objects as properties values other than plain numbers, booleans, and strings. Plus, Neo4j doesn't store either null or empty property values.

Yorkst commented 8 years ago

My neo4j sure does

create (t:Test {data: []})

match(t:Test) return t.data

Neo4j

versae commented 8 years ago

Does that work through the REST API using the API methods and not Cypher queries? I'll double check.

versae commented 8 years ago

Just tried with 2.2.10 and 2.3.7 and got this:

$ curl -H "Content-Type: application/json" -X POST http://localhost:7474/db/data/node -d '{"prop": []}'
{
  "message" : "Unable to set property 'prop' to an empty array, because, since there are no values of any type in it, and no pre-existing collection to infer type from, it is not possible to determine what type of array to store.",
  "exception" : "PropertyValueException",
  "fullname" : "org.neo4j.server.rest.web.PropertyValueException",
  "stackTrace" : [ "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperty(PropertySettingStrategy.java:120)", "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperties(PropertySettingStrategy.java:88)", "org.neo4j.server.rest.web.DatabaseActions.createNode(DatabaseActions.java:205)", "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:252)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)", "java.lang.Thread.run(Thread.java:745)" ],
  "errors" : [ {
    "message" : "Unable to set property 'prop' to an empty array, because, since there are no values of any type in it, and no pre-existing collection to infer type from, it is not possible to determine what type of array to store.",
    "code" : "Neo.ClientError.Statement.InvalidArguments"
  } ]
}