Imagine that you want to restrict delete action on entities with relation by other entities.
And you don't want/can't use cascade behavior.
In such case you need to do additional query (or maybe much more if relation has fetch eager fields) for every entity in index page.
With proposed fix you can addSelect in createIndexQueryBuilder and it will be mapped correctly.
For example you have Category and Product and want to restrict delete category if it has products.
As bonus you can get product count in category within one query.
Like
// Category entity
public $productsCount;
//Category crud controller
public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
{
$qb = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);
$qb->leftJoin('entity.products', 'p')->addSelect('COUNT(p.id) AS productsCount');
return $qb;
}
Imagine that you want to restrict delete action on entities with relation by other entities. And you don't want/can't use cascade behavior. In such case you need to do additional query (or maybe much more if relation has fetch eager fields) for every entity in index page.
With proposed fix you can
addSelect
increateIndexQueryBuilder
and it will be mapped correctly. For example you have Category and Product and want to restrict delete category if it has products. As bonus you can get product count in category within one query. Like