We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cypher's CREATE clause supports reusing variables that were matched elsewhere in the query to create new relationships. For example:
CREATE
MATCH (charlie:Person {name: 'Charlie Sheen'}), (oliver:Person {name: 'Oliver Stone'}) CREATE (charlie)-[:ACTED_IN {role: 'Bud Fox'}]->(wallStreet:Movie {title: 'Wall Street'})<-[:DIRECTED]-(oliver)
However, this is not properly supported in php-cypher-dsl (see example below).
$charlie = node("Person")->withProperties(["name" => "Charlie Sheen"]); $oliver = node("Person")->withProperties(["name" => "Oliver Stone"]); $wallStreet = node("Movie")->withProperties(["title" => "Wall Street"]); $query = query() ->match([$charlie, $oliver]) ->create($charlie->relationshipTo($wallStreet, type: "ACTED_IN", properties: ["role" => "Bud Fox"])->relationshipFrom($oliver)) ->build();
This gives:
MATCH (:Person {name: 'Charlie Sheen'}), (:Person {name: 'Oliver Stone'}) CREATE (:Person {name: 'Charlie Sheen'})-[:ACTED_IN {role: 'Bud Fox'}]->(:Movie {title: 'Wall Street'})<--(:Person {name: 'Oliver Stone'})
MATCH (charlie:Person {name: 'Charlie Sheen'}), (oliver:Person {name: 'Oliver Stone'}) CREATE (charlie)-[:ACTED_IN {role: 'Bud Fox'}]->(:Movie {title: 'Wall Street'})<--(oliver)
A workaround exists by first retrieving the variable of the node, and then creating a new node with that variable. This is syntactically rather ugly:
$query = query() ->match([$charlie, $oliver]) ->create(node()->withVariable($charlie->getVariable())->relationshipTo($wallStreet, type: "ACTED_IN", properties: ["role" => "Bud Fox"])->relationshipFrom(node()->withVariable($oliver->getVariable()))) ->build();
The text was updated successfully, but these errors were encountered:
+1
Am facing the same problem
Sorry, something went wrong.
No branches or pull requests
Bug report
Cypher's
CREATE
clause supports reusing variables that were matched elsewhere in the query to create new relationships. For example:However, this is not properly supported in php-cypher-dsl (see example below).
Code snippet that reproduces the problem
This gives:
Expected output
A workaround exists by first retrieving the variable of the node, and then creating a new node with that variable. This is syntactically rather ugly:
The text was updated successfully, but these errors were encountered: