neo4jphp icon indicating copy to clipboard operation
neo4jphp copied to clipboard

addLabels to node fails in Batch mode

Open mcuadros opened this issue 11 years ago • 3 comments

Hi,

I am very new with neo4j and of course with neo4jphp, so i dont know if i am missing something.

When the batch mode is on and i create a node and after i add label, then throw an exception about the node is not saved

$batch = $this->neo4->startBatch();
$label = $this->neo4j->makeLabel(self::LABEL_USER);

$partner = $this->neo4j->makeNode();
$partner
    ->setProperty('mongoId', (string) $origin->getId())
    ->setProperty('slug', $origin->getSlug())
    ->setProperty('name', $origin->getName())
    ->save();

$node->addLabels([$label]);

$batch->commit();

How i can create a node and add a label in batch mode? Is this possible?

Regards and thanks

mcuadros avatar Oct 19 '13 03:10 mcuadros

Hello I have the same problem, someone can help or explain another way to do this.

Regards

jquequezana avatar Nov 02 '13 03:11 jquequezana

I made a PR but i not accepted because in under way another implementation.

https://github.com/jadell/neo4jphp/pull/95

mcuadros avatar Nov 03 '13 18:11 mcuadros

I think that i found some solution... @ Everyman\Neo4j\Command\SetLabels on __constructor

    $nodeId = $node->getId();
    if (!$nodeId) {
            throw new \InvalidArgumentException("Cannot set labels on an unsaved node");
    }

to

    $nodeId = $node->getId();
    if (!$nodeId) {
        if($nodeId != 0)
        {
            throw new \InvalidArgumentException("Cannot set labels on an unsaved node");
        }
    }

Some times the $node is equles to 0 and it comfusing between false and Node#0

ghost avatar Jan 16 '14 21:01 ghost