Skip to content

Commit e73c318

Browse files
committed
wip improve statement generation
1 parent 4288208 commit e73c318

8 files changed

+14
-26
lines changed

src/EventListener/OpenCypher/NodeMergeToStatementEventListener.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ public static function nodeStatement(NodeInterface $node): Statement
4545
return new Statement(
4646
sprintf(
4747
"MERGE (node%s {%s})\n".
48-
"ON CREATE\n".
49-
" SET node += \$properties\n".
50-
"ON MATCH\n".
51-
" SET node += \$properties",
48+
"SET node += \$properties",
5249
ToCypherHelper::nodeLabelStorageToCypherLabelString($node->getNodeLabels()),
5350
StructureHelper::getIdentifiersFromElementAsCypherVariableString($node, '$identifier')
5451
),

src/EventListener/OpenCypher/SimilarNodeQueueCreateToStatementEventListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public static function similarNodeQueueStatement(SimilarNodeQueueInterface $simi
6262
return new Statement(
6363
sprintf(
6464
"UNWIND \$batch as row\n".
65-
"CREATE (n%s {%s})\n".
66-
"SET n += row.property",
65+
"CREATE (node%s {%s})\n".
66+
"SET node += row.property",
6767
ToCypherHelper::nodeLabelStorageToCypherLabelString($firstNode->getNodeLabels()),
6868
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstNode, 'row.identifier')
6969
),

src/EventListener/OpenCypher/SimilarNodeQueueDeleteToStatementEventListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public static function similarNodeQueueStatement(SimilarNodeQueueInterface $simi
5959
return new Statement(
6060
sprintf(
6161
"UNWIND \$batch as row\n".
62-
"MATCH (n%s {%s})\n".
63-
"DETACH DELETE n",
62+
"MATCH (node%s {%s})\n".
63+
"DETACH DELETE node",
6464
ToCypherHelper::nodeLabelStorageToCypherLabelString($firstNode->getNodeLabels()),
6565
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstNode, 'row')
6666
),

src/EventListener/OpenCypher/SimilarNodeQueueMergeToStatementEventListener.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,8 @@ public static function similarNodeQueueStatement(SimilarNodeQueueInterface $simi
6262
return new Statement(
6363
sprintf(
6464
"UNWIND \$batch as row\n".
65-
"MERGE (n%s {%s})\n".
66-
"ON CREATE\n".
67-
" SET n += row.property\n".
68-
"ON MATCH\n".
69-
" SET n += row.property",
65+
"MERGE (node%s {%s})\n".
66+
"SET node += row.property",
7067
ToCypherHelper::nodeLabelStorageToCypherLabelString($firstNode->getNodeLabels()),
7168
StructureHelper::getIdentifiersFromElementAsCypherVariableString($firstNode, 'row.identifier')
7269
),

tests/EventListener/OpenCypher/NodeMergeToStatementEventListenerTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,7 @@ public function testNodeStatement(): void
8484

8585
$this->assertSame(
8686
"MERGE (node:NodeLabel {id: \$identifier.id})\n".
87-
"ON CREATE\n".
88-
" SET node += \$properties\n".
89-
"ON MATCH\n".
90-
" SET node += \$properties",
87+
"SET node += \$properties",
9188
$statement->getText()
9289
);
9390
$this->assertCount(2, $statement->getParameters());

tests/EventListener/OpenCypher/SimilarNodeQueueCreateToStatementEventListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public function testNodeStatement(): void
147147

148148
$this->assertSame(
149149
"UNWIND \$batch as row\n".
150-
"CREATE (n:Node {identifier: row.identifier.identifier})\n".
151-
"SET n += row.property",
150+
"CREATE (node:Node {identifier: row.identifier.identifier})\n".
151+
"SET node += row.property",
152152
$statement->getText()
153153
);
154154
$this->assertCount(1, $statement->getParameters());

tests/EventListener/OpenCypher/SimilarNodeQueueDeleteToStatementEventListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public function testNodeStatement(): void
140140

141141
$this->assertSame(
142142
"UNWIND \$batch as row\n".
143-
"MATCH (n:Node {identifier: row.identifier})\n".
144-
"DETACH DELETE n",
143+
"MATCH (node:Node {identifier: row.identifier})\n".
144+
"DETACH DELETE node",
145145
$statement->getText()
146146
);
147147
$this->assertCount(1, $statement->getParameters());

tests/EventListener/OpenCypher/SimilarNodeQueueMergeToStatementEventListenerTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,8 @@ public function testNodeStatement(): void
140140

141141
$this->assertSame(
142142
"UNWIND \$batch as row\n".
143-
"MERGE (n:Node {identifier: row.identifier.identifier})\n".
144-
"ON CREATE\n".
145-
" SET n += row.property\n".
146-
"ON MATCH\n".
147-
" SET n += row.property",
143+
"MERGE (node:Node {identifier: row.identifier.identifier})\n".
144+
"SET node += row.property",
148145
$statement->getText()
149146
);
150147
$this->assertCount(1, $statement->getParameters());

0 commit comments

Comments
 (0)