sulu / sulu-document-manager

Sulu document manager
sulu.io
6 stars 7 forks source link

QueryResultCollection is unaware of primarySelector that was set for a query #111

Open Edvinas9 opened 7 years ago

Edvinas9 commented 7 years ago

QueryResultCollection is unaware of primarySelector that was set for a query. It has to be aware of primarySelector because it's using PHPCR-ODM's Row::getNode() method where primarySelector is required to work properly for queries that have SQL joins.

Because of this issue it is impossible to use SQL joins in queries generated by DocumentManager::createQuery().

I look forward to elaborate this issue further and possibly create a PR soon. Meanwhile, reflection can be used as a temporary solution to set primarySelector:

$query = $documentManager->createQuery(...);
$result = $query->execute();
$reflection = new \ReflectionProperty(get_class($result), 'primarySelector');
$reflection->setAccessible(true);
$reflection->setValue($result, 'i'); //put your primarySelector as a 2nd parameter