2

I'm updating a node and pushing it:

remote_graph.push(node)

push() seems to return nothing. How can I tell if the push works? In my test code, I ought to be violating a unique constraint in Neo4J.

How can I tell using py2neo? I expected an exception.

When I enter the equivalent cypher into the Neo4J web tool, I get the following exception:

Node 322184 already exists with label VERSION and property "version"=[1.436818928448956E9]

which is what I expected.

Edit - What I expected to get back was an indicator of whether the operation worked or not. I think push() accepts an array of nodes, so an array of results would be sensible. I don't know what the indicator would have within it since I don't know what is available. An array of strings would be fine, with each string being a failure reason, or "OK".

Tony Ennis
  • 12,000
  • 7
  • 52
  • 73

1 Answers1

2

Generally speaking, the design of this API is: if it returns OK, you can assume everything has worked as expected, if an error is raised, that error will contain details of what went wrong. Therefore, absence of error should usually be interpreted as a signal of success.

That said, if you believe that your push has failed and no error has been raised, there is a bug in py2neo. For debugging, you can check the state of the database after your push by using the browser and then if you're able to recreate this scenario in a standalone piece of code, please raise an issue on GitHub and I will be happy to fix it.

Nigel Small
  • 4,475
  • 1
  • 17
  • 15