Skip to content

Commit

Permalink
TASK: Dont select contentstreamid from node row
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Mar 15, 2024
1 parent d24324b commit 0deca11
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function countBackReferences(NodeAggregateId $nodeAggregateId, CountBackR
public function findNodeById(NodeAggregateId $nodeAggregateId): ?Node
{
$queryBuilder = $this->createQueryBuilder()
->select('n.*, h.name, h.subtreetags, h.contentstreamid')
->select('n.*, h.name, h.subtreetags')
->from($this->tableNamePrefix . '_node', 'n')
->innerJoin('n', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.childnodeanchor = n.relationanchorpoint')
->where('n.nodeaggregateid = :nodeAggregateId')->setParameter('nodeAggregateId', $nodeAggregateId->value)
Expand All @@ -182,7 +182,7 @@ public function findNodeById(NodeAggregateId $nodeAggregateId): ?Node
public function findRootNodeByType(NodeTypeName $nodeTypeName): ?Node
{
$queryBuilder = $this->createQueryBuilder()
->select('n.*, h.name, h.subtreetags, h.contentstreamid')
->select('n.*, h.name, h.subtreetags')
->from($this->tableNamePrefix . '_node', 'n')
->innerJoin('n', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.childnodeanchor = n.relationanchorpoint')
->where('n.nodetypename = :nodeTypeName')->setParameter('nodeTypeName', $nodeTypeName->value)
Expand All @@ -197,7 +197,7 @@ public function findRootNodeByType(NodeTypeName $nodeTypeName): ?Node
public function findParentNode(NodeAggregateId $childNodeAggregateId): ?Node
{
$queryBuilder = $this->createQueryBuilder()
->select('pn.*, ch.name, ch.subtreetags, ph.contentstreamid')
->select('pn.*, ch.name, ch.subtreetags')
->from($this->tableNamePrefix . '_node', 'pn')
->innerJoin('pn', $this->tableNamePrefix . '_hierarchyrelation', 'ph', 'ph.parentnodeanchor = pn.relationanchorpoint')
->innerJoin('pn', $this->tableNamePrefix . '_node', 'cn', 'cn.relationanchorpoint = ph.childnodeanchor')
Expand Down Expand Up @@ -239,7 +239,7 @@ public function findNodeByAbsolutePath(AbsoluteNodePath $path): ?Node
private function findChildNodeConnectedThroughEdgeName(NodeAggregateId $parentNodeAggregateId, NodeName $nodeName): ?Node
{
$queryBuilder = $this->createQueryBuilder()
->select('cn.*, h.name, h.subtreetags, h.contentstreamid')
->select('cn.*, h.name, h.subtreetags')
->from($this->tableNamePrefix . '_node', 'pn')
->innerJoin('pn', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.parentnodeanchor = pn.relationanchorpoint')
->innerJoin('pn', $this->tableNamePrefix . '_node', 'cn', 'cn.relationanchorpoint = h.childnodeanchor')
Expand Down Expand Up @@ -290,7 +290,7 @@ public function findSubtree(NodeAggregateId $entryNodeAggregateId, FindSubtreeFi
{
$queryBuilderInitial = $this->createQueryBuilder()
// @see https://mariadb.com/kb/en/library/recursive-common-table-expressions-overview/#cast-to-avoid-data-truncation
->select('n.*, h.name, h.subtreetags, h.contentstreamid, CAST("ROOT" AS CHAR(50)) AS parentNodeAggregateId, 0 AS level, 0 AS position')
->select('n.*, h.name, h.subtreetags, CAST("ROOT" AS CHAR(50)) AS parentNodeAggregateId, 0 AS level, 0 AS position')
->from($this->tableNamePrefix . '_node', 'n')
->innerJoin('n', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.childnodeanchor = n.relationanchorpoint')
->where('h.contentstreamid = :contentStreamId')
Expand All @@ -299,7 +299,7 @@ public function findSubtree(NodeAggregateId $entryNodeAggregateId, FindSubtreeFi
$this->addSubtreeTagConstraints($queryBuilderInitial);

$queryBuilderRecursive = $this->createQueryBuilder()
->select('c.*, h.name, h.subtreetags, h.contentstreamid, p.nodeaggregateid AS parentNodeAggregateId, p.level + 1 AS level, h.position')
->select('c.*, h.name, h.subtreetags, p.nodeaggregateid AS parentNodeAggregateId, p.level + 1 AS level, h.position')
->from('tree', 'p')
->innerJoin('p', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.parentnodeanchor = p.relationanchorpoint')
->innerJoin('p', $this->tableNamePrefix . '_node', 'c', 'c.relationanchorpoint = h.childnodeanchor')
Expand Down Expand Up @@ -382,7 +382,7 @@ public function countAncestorNodes(NodeAggregateId $entryNodeAggregateId, CountA
public function findClosestNode(NodeAggregateId $entryNodeAggregateId, FindClosestNodeFilter $filter): ?Node
{
$queryBuilderInitial = $this->createQueryBuilder()
->select('n.*, ph.name, ph.subtreetags, ph.contentstreamid, ph.parentnodeanchor')
->select('n.*, ph.name, ph.subtreetags, ph.parentnodeanchor')
->from($this->tableNamePrefix . '_node', 'n')
// we need to join with the hierarchy relation, because we need the node name.
->innerJoin('n', $this->tableNamePrefix . '_hierarchyrelation', 'ph', 'n.relationanchorpoint = ph.childnodeanchor')
Expand All @@ -392,7 +392,7 @@ public function findClosestNode(NodeAggregateId $entryNodeAggregateId, FindClose
$this->addSubtreeTagConstraints($queryBuilderInitial, 'ph');

$queryBuilderRecursive = $this->createQueryBuilder()
->select('pn.*, h.name, h.subtreetags, h.contentstreamid, h.parentnodeanchor')
->select('pn.*, h.name, h.subtreetags, h.parentnodeanchor')
->from('ancestry', 'cn')
->innerJoin('cn', $this->tableNamePrefix . '_node', 'pn', 'pn.relationanchorpoint = cn.parentnodeanchor')
->innerJoin('pn', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.childnodeanchor = pn.relationanchorpoint')
Expand Down Expand Up @@ -602,7 +602,7 @@ private function searchPropertyValueStatement(QueryBuilder $queryBuilder, Proper
private function buildChildNodesQuery(NodeAggregateId $parentNodeAggregateId, FindChildNodesFilter|CountChildNodesFilter $filter): QueryBuilder
{
$queryBuilder = $this->createQueryBuilder()
->select('n.*, h.name, h.subtreetags, h.contentstreamid')
->select('n.*, h.name, h.subtreetags')
->from($this->tableNamePrefix . '_node', 'pn')
->innerJoin('pn', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.parentnodeanchor = pn.relationanchorpoint')
->innerJoin('pn', $this->tableNamePrefix . '_node', 'n', 'h.childnodeanchor = n.relationanchorpoint')
Expand All @@ -627,7 +627,7 @@ private function buildReferencesQuery(bool $backReferences, NodeAggregateId $nod
$sourceTablePrefix = $backReferences ? 'd' : 's';
$destinationTablePrefix = $backReferences ? 's' : 'd';
$queryBuilder = $this->createQueryBuilder()
->select("{$destinationTablePrefix}n.*, {$destinationTablePrefix}h.name, {$destinationTablePrefix}h.subtreetags, {$destinationTablePrefix}h.contentstreamid, r.name AS referencename, r.properties AS referenceproperties")
->select("{$destinationTablePrefix}n.*, {$destinationTablePrefix}h.name, {$destinationTablePrefix}h.subtreetags, r.name AS referencename, r.properties AS referenceproperties")
->from($this->tableNamePrefix . '_hierarchyrelation', 'sh')
->innerJoin('sh', $this->tableNamePrefix . '_node', 'sn', 'sn.relationanchorpoint = sh.childnodeanchor')
->innerJoin('sh', $this->tableNamePrefix . '_referencerelation', 'r', 'r.nodeanchorpoint = sn.relationanchorpoint')
Expand Down Expand Up @@ -695,7 +695,7 @@ private function buildSiblingsQuery(bool $preceding, NodeAggregateId $siblingNod
->andWhere('sh.dimensionspacepointhash = :dimensionSpacePointHash');

$queryBuilder = $this->createQueryBuilder()
->select('n.*, h.name, h.subtreetags, h.contentstreamid')
->select('n.*, h.name, h.subtreetags')
->from($this->tableNamePrefix . '_node', 'n')
->innerJoin('n', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.childnodeanchor = n.relationanchorpoint')
->where('h.contentstreamid = :contentStreamId')->setParameter('contentStreamId', $this->contentStreamId->value)
Expand Down Expand Up @@ -727,7 +727,7 @@ private function buildSiblingsQuery(bool $preceding, NodeAggregateId $siblingNod
private function buildAncestorNodesQueries(NodeAggregateId $entryNodeAggregateId, FindAncestorNodesFilter|CountAncestorNodesFilter|FindClosestNodeFilter $filter): array
{
$queryBuilderInitial = $this->createQueryBuilder()
->select('n.*, ph.name, ph.subtreetags, ph.contentstreamid, ph.parentnodeanchor')
->select('n.*, ph.name, ph.subtreetags, ph.parentnodeanchor')
->from($this->tableNamePrefix . '_node', 'n')
// we need to join with the hierarchy relation, because we need the node name.
->innerJoin('n', $this->tableNamePrefix . '_hierarchyrelation', 'ch', 'ch.parentnodeanchor = n.relationanchorpoint')
Expand All @@ -742,7 +742,7 @@ private function buildAncestorNodesQueries(NodeAggregateId $entryNodeAggregateId
$this->addSubtreeTagConstraints($queryBuilderInitial, 'ch');

$queryBuilderRecursive = $this->createQueryBuilder()
->select('pn.*, h.name, h.subtreetags, h.contentstreamid, h.parentnodeanchor')
->select('pn.*, h.name, h.subtreetags, h.parentnodeanchor')
->from('ancestry', 'cn')
->innerJoin('cn', $this->tableNamePrefix . '_node', 'pn', 'pn.relationanchorpoint = cn.parentnodeanchor')
->innerJoin('pn', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.childnodeanchor = pn.relationanchorpoint')
Expand All @@ -769,7 +769,7 @@ private function buildDescendantNodesQueries(NodeAggregateId $entryNodeAggregate
{
$queryBuilderInitial = $this->createQueryBuilder()
// @see https://mariadb.com/kb/en/library/recursive-common-table-expressions-overview/#cast-to-avoid-data-truncation
->select('n.*, h.name, h.subtreetags, h.contentstreamid, CAST("ROOT" AS CHAR(50)) AS parentNodeAggregateId, 0 AS level, 0 AS position')
->select('n.*, h.name, h.subtreetags, CAST("ROOT" AS CHAR(50)) AS parentNodeAggregateId, 0 AS level, 0 AS position')
->from($this->tableNamePrefix . '_node', 'n')
// we need to join with the hierarchy relation, because we need the node name.
->innerJoin('n', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.childnodeanchor = n.relationanchorpoint')
Expand All @@ -783,7 +783,7 @@ private function buildDescendantNodesQueries(NodeAggregateId $entryNodeAggregate
$this->addSubtreeTagConstraints($queryBuilderInitial);

$queryBuilderRecursive = $this->createQueryBuilder()
->select('cn.*, h.name, h.subtreetags, h.contentstreamid, pn.nodeaggregateid AS parentNodeAggregateId, pn.level + 1 AS level, h.position')
->select('cn.*, h.name, h.subtreetags, pn.nodeaggregateid AS parentNodeAggregateId, pn.level + 1 AS level, h.position')
->from('tree', 'pn')
->innerJoin('pn', $this->tableNamePrefix . '_hierarchyrelation', 'h', 'h.parentnodeanchor = pn.relationanchorpoint')
->innerJoin('pn', $this->tableNamePrefix . '_node', 'cn', 'cn.relationanchorpoint = h.childnodeanchor')
Expand Down

0 comments on commit 0deca11

Please sign in to comment.