This happens, when you sort by the relation:
?action=list&entity=Subscription&menuIndex=0&submenuIndex=-1&sortField=transaction&sortDirection=DESC&page=1
Argument 1 passed to Doctrine\ORM\Mapping\DefaultQuoteStrategy::getJoinColumnName()
must be of the type array, boolean given
It seems that is caused by a OneToOne relation:
/**
* @ORM\OneToOne(targetEntity="AppBundle\Entity\Transaction", mappedBy="subscription")
*/
private $transaction;
Similar happening to me on 1.12.6, symfony 2.8.4, Doctrine Bundle 1.4
[2/2] An exception has been thrown during the rendering of a template ("Notice: Undefined index: airportData") in @EasyAdmin/default/list.html.twig at line 129.
[1/2] ContextErrorException: Notice: Undefined index: airportData -
in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php at line 40
When trying to sort by OneToOne
/**
* @var string
*
* @ORM\OneToOne(targetEntity="AppBundle\Entity\AirportsMasterData", fetch="EAGER")
*/
private $airportData;
Found the issue (at least part of it) in Search/Paginator.php
$paginator = new Pagerfanta(new DoctrineORMAdapter($queryBuilder, true, false));
DoctrineORMAdapter second parameter ($fetchJoinCollection), if set to true returns Object without associated field, if set to false returns Object with associated field.
Investigating further...
I'm possibly hijacking this issue, as my issue might be different but still related.
Let me know if you want me to open new issue.
On the matter:
I was able to fix my issue by defining custom ListQueryBuilder where I'm explicitly joining my relation.
Relation (One To One unidirectional):
/**
* @var string
*
* @ORM\OneToOne(targetEntity="AppBundle\Entity\AirportsMasterData", fetch="EAGER")
*/
private $airportData;
Custom ListQueryBuilder:
protected function createMonitoredAirportsListQueryBuilder($entityConfig, $sortDirection, $sortField)
{
/** @var EntityManager */
$em = $this->get('doctrine')->getManagerForClass($entityConfig);
$queryBuilder = $em->createQueryBuilder()
->select(array('entity', 'ad'))
->from($entityConfig, 'entity')
->leftJoin('entity.airportData', 'ad');
if (null !== $sortField) {
if ($sortField == "airportData") {
$queryBuilder->orderBy('ad.airportIcao', $sortDirection);
} else {
$queryBuilder->orderBy('entity.'.$sortField, $sortDirection);
}
}
return $queryBuilder;
}
Note that I'm joining on my OneToOne relation and then doing custom orderBy if sortField is my OneToOne relation.
Snippet of my AirportsMasterData:
class AirportsMasterData
{
public function __toString()
{
return $this->airportIcao;
}
/**
* @var string
*
* @ORM\Column(name="airport_icao", type="string", length=4, unique=true)
*/
private $airportIcao;
Questions I have remaining:
Dear @javiereguiluz , appreciate if you can comment whenever possible.
Closing it as (probably) fixed by #1392, which allows to sort results by any property of a Doctrine association.
Hi, I still have this problem with EasyAdmin 1.17.19, Symfony 4.2.1, Doctrine Bundle 1.10
When I try to order an entity from the 'list' action by another entity which has a one-to-one relationship and its relation has not yet been defined or was eliminated (that is, it has null value as a relation) I get this error:
Argument 1 passed to Doctrine\ORM\Mapping\DefaultQuoteStrategy::getJoinColumnName() must be of the type array, boolean given, called in C:\test\Emdupar\vendor\doctrine\orm\lib\Doctrine\ORM\Query\AST\Functions\IdentityFunction.php on line 89
/**
* @ORM\OneToOne(
* targetEntity="App\Entity\Model\InvoiceOwnerInterface",
* mappedBy="invoice",
* cascade={"persist","remove"}
* )
*/
private $service;
@TavoNiievez Me, too!
Most helpful comment
Hi, I still have this problem with EasyAdmin 1.17.19, Symfony 4.2.1, Doctrine Bundle 1.10
When I try to order an entity from the 'list' action by another entity which has a one-to-one relationship and its relation has not yet been defined or was eliminated (that is, it has null value as a relation) I get this error: