Skip to content
New issue

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

!!! BUGFIX: Actually execute moveSubtreeTags tests and fix moveSubtreeTags #5025

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ private function whenNodeAggregateWasMoved(NodeAggregateWasMoved $event): void
);
$this->moveSubtreeTags(
$event->contentStreamId,
$event->nodeAggregateId,
$event->newParentNodeAggregateId,
$succeedingSiblingForCoverage->dimensionSpacePoint
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,11 @@ private function whenSubtreeWasUntagged(SubtreeWasUntagged $event): void
]);
}

private function moveSubtreeTags(ContentStreamId $contentStreamId, NodeAggregateId $nodeAggregateId, NodeAggregateId $newParentNodeAggregateId, DimensionSpacePoint $coveredDimensionSpacePoint): void
{
private function moveSubtreeTags(
ContentStreamId $contentStreamId,
NodeAggregateId $newParentNodeAggregateId,
DimensionSpacePoint $coveredDimensionSpacePoint
): void {
$this->getDatabaseConnection()->executeStatement('
UPDATE ' . $this->getTableNamePrefix() . '_hierarchyrelation h,
(
Expand All @@ -146,20 +149,36 @@ private function moveSubtreeTags(ContentStreamId $contentStreamId, NodeAggregate
' . $this->getTableNamePrefix() . '_hierarchyrelation th
INNER JOIN ' . $this->getTableNamePrefix() . '_node tn ON tn.relationanchorpoint = th.childnodeanchor
WHERE
tn.nodeaggregateid = :nodeAggregateId
tn.nodeaggregateid = :newParentNodeAggregateId
AND th.contentstreamid = :contentStreamId
AND th.dimensionspacepointhash = :dimensionSpacePointHash
UNION
SELECT JSON_MERGE(cte.subtreetagsToInherit, JSON_KEYS(JSON_MERGE_PATCH(\'{}\', dh.subtreetags))) subtreeTagsToInherit, dh.childnodeanchor
SELECT
JSON_MERGE_PRESERVE(
nezaniel marked this conversation as resolved.
Show resolved Hide resolved
cte.subtreeTagsToInherit,
JSON_KEYS(JSON_MERGE_PATCH(
\'{}\',
dh.subtreetags
))
) subtreeTagsToInherit,
dh.childnodeanchor
FROM
cte
JOIN ' . $this->getTableNamePrefix() . '_hierarchyrelation dh ON dh.parentnodeanchor = cte.childnodeanchor
JOIN ' . $this->getTableNamePrefix() . '_hierarchyrelation dh
ON
dh.parentnodeanchor = cte.childnodeanchor
WHERE
dh.contentstreamid = :contentStreamId
AND dh.dimensionspacepointhash = :dimensionSpacePointHash
nezaniel marked this conversation as resolved.
Show resolved Hide resolved
)
SELECT * FROM cte
) AS r
SET h.subtreetags = (
SELECT
JSON_MERGE_PATCH(JSON_OBJECTAGG(htk.k, null), JSON_MERGE_PATCH(\'{}\', h.subtreetags))
JSON_MERGE_PATCH(
IFNULL(JSON_OBJECTAGG(htk.k, null), \'{}\'),
JSON_MERGE_PATCH(\'{}\', h.subtreetags)
)
FROM
JSON_TABLE(r.subtreeTagsToInherit, \'$[*]\' COLUMNS (k VARCHAR(36) PATH \'$\')) htk
)
Expand All @@ -169,7 +188,7 @@ private function moveSubtreeTags(ContentStreamId $contentStreamId, NodeAggregate
AND h.dimensionspacepointhash = :dimensionSpacePointHash
', [
'contentStreamId' => $contentStreamId->value,
'nodeAggregateId' => $newParentNodeAggregateId->value,
'newParentNodeAggregateId' => $newParentNodeAggregateId->value,
'dimensionSpacePointHash' => $coveredDimensionSpacePoint->hash,
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ public function iExpectTheNodeWithAggregateIdentifierToNotContainTheTag(string $
public function iExpectThisNodeToBeExactlyExplicitlyTagged(string $expectedTagList): void
{
$this->assertOnCurrentNode(function (Node $currentNode) use ($expectedTagList) {
$actualTags = $currentNode->tags->withoutInherited()->toStringArray();
sort($actualTags);
Assert::assertSame(
($expectedTagList === '') ? [] : explode(',', $expectedTagList),
$currentNode->tags->withoutInherited()->toStringArray()
$actualTags
);
});
}
Expand All @@ -262,9 +264,11 @@ public function iExpectThisNodeToBeExactlyExplicitlyTagged(string $expectedTagLi
public function iExpectThisNodeToExactlyInheritTheTags(string $expectedTagList): void
{
$this->assertOnCurrentNode(function (Node $currentNode) use ($expectedTagList) {
$actualTags = $currentNode->tags->onlyInherited()->toStringArray();
sort($actualTags);
Assert::assertSame(
($expectedTagList === '') ? [] : explode(',', $expectedTagList),
$currentNode->tags->onlyInherited()->toStringArray(),
$actualTags,
);
});
}
Expand Down
Loading