Compare commits

..

No commits in common. "585d469b695365e6f8c0f9b596dbb18b6d3ce584" and "fd286c9cffadc4a26609bfa00944f8014a2f3f59" have entirely different histories.

View File

@ -150,7 +150,7 @@ class PersistentDataManager implements IPersistentDataManager
$columns = array_merge($columns, $this->getRelationColumns($table, $relations, $withRelations)); $columns = array_merge($columns, $this->getRelationColumns($table, $relations, $withRelations));
$this->leftJoinRelations($select, $table, $table, $relations, $withRelations); $this->leftJoinRelations($select, $table, $relations, $withRelations);
$select->columns($columns); $select->columns($columns);
} else { } else {
$select->columns($columns); $select->columns($columns);
@ -180,19 +180,19 @@ class PersistentDataManager implements IPersistentDataManager
return $columns; return $columns;
} }
private function leftJoinRelations(Select $select, string $table, string $tableAlias, array $relations, array $withRelations): void private function leftJoinRelations(Select $select, string $table, array $relations, array $withRelations): void
{ {
foreach ($relations as $relation => $relationType) { foreach ($relations as $relation => $relationType) {
$relationTableAlias = $table . '__' . $relation; $relationTableAlias = $table . '__' . $relation;
$relationTable = call_user_func([$relationType, 'getTable']); $relationTable = call_user_func([$relationType, 'getTable']);
$select->setTableAliases([$relationTableAlias => $relationTable]); $select->setTableAliases([$relationTableAlias => $relationTable]);
$select->leftJoin($relationTableAlias, [$relationTableAlias, 'id'], '=', [$tableAlias, $relation . '_id']); $select->leftJoin($relationTableAlias, [$relationTableAlias, 'id'], '=', [$table, $relation . '_id']);
$relationsOfRelation = call_user_func([$relationType, 'getRelations']); $relationsOfRelation = call_user_func([$relationType, 'getRelations']);
if (count($withRelations)) { if (count($withRelations)) {
$relationsOfRelation = array_intersect_key($relationsOfRelation, array_flip($withRelations)); $relationsOfRelation = array_intersect_key($relationsOfRelation, array_flip($withRelations));
} }
$this->leftJoinRelations($select, $relationTable, $relationTableAlias, $relationsOfRelation, $withRelations); $this->leftJoinRelations($select, $relationTable, $relationsOfRelation, $withRelations);
} }
} }