diff --git a/eZ/Publish/Core/Persistence/Legacy/Filter/CriterionQueryBuilder/Content/ObjectStateIdQueryBuilder.php b/eZ/Publish/Core/Persistence/Legacy/Filter/CriterionQueryBuilder/Content/ObjectStateIdQueryBuilder.php index fcb0f5821d..929b5236b2 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Filter/CriterionQueryBuilder/Content/ObjectStateIdQueryBuilder.php +++ b/eZ/Publish/Core/Persistence/Legacy/Filter/CriterionQueryBuilder/Content/ObjectStateIdQueryBuilder.php @@ -29,19 +29,23 @@ public function buildQueryConstraint( FilteringQueryBuilder $queryBuilder, FilteringCriterion $criterion ): ?string { + static $counter = 1; + $tableAlias = 'object_state_link_' . $counter; + ++$counter; + /** @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ObjectStateId $criterion */ $queryBuilder ->joinOnce( 'content', Gateway::OBJECT_STATE_LINK_TABLE, - 'object_state_link', - 'content.id = object_state_link.contentobject_id', + $tableAlias, + 'content.id = ' . $tableAlias . '.contentobject_id', ); $value = (array)$criterion->value; return $queryBuilder->expr()->in( - 'object_state_link.contentobject_state_id', + $tableAlias . '.contentobject_state_id', $queryBuilder->createNamedParameter($value, Connection::PARAM_INT_ARRAY) ); }