I’m using graphaware/neo4j-php-client 4.5.1 with Neo4j 3.0.4 on PHP 5.6.24.
I don’t understand how to find out whether a transaction has failed.
For example, I try to delete a node that still has relationships. If I run the DELETE in this simple query:
$client->run
(
'MATCH (node { name: {name} }) DELETE node',
[ 'name' => 'Fred' ]
);
… I get this exception, which is the behaviour I expected:
[GraphAware\Neo4j\Client\Exception\Neo4jException]
org.neo4j.kernel.api.exceptions.ConstraintViolationTransactionFailureException:
Cannot delete node<31>, because it still has relationships.
To delete this node, you must first delete its relationships.
But when I wrap that same query inside a transaction:
$transaction = $client->transaction();
$transaction->push
(
'MATCH (node { name: {name} }) DELETE node',
[ 'name' => 'Fred' ]
);
$results = $transaction->commit();
foreach ($results as $result)
{
$summary = $result->summarize();
$stats = $summary->updateStatistics();
printf("Nodes deleted: %d\n", $stats->nodesDeleted());
}
printf("Transaction status: %s\n", $transaction->status());
… Neo4j doesn’t delete the node, but I see this (suggesting success) instead of an exception:
Nodes deleted: 1
Transaction status: COMMITED
Am I missing anything, or is this a bug? Thanks in advance!