| Q | A
|------------ | -----
| Doctrine\ORM\Tools\Pagination\CountWalker | 2.6.1
Why CountWalker is not support Entity with composite key?
$identifierFieldName = $rootClass->getSingleIdentifierFieldName();
Throw exception Single id is not allowed on composite primary key in entity Entity
I've also been having that issue. I've been attempting to see why EasyAdmin and Pagerfanta don't work with composite keys because Doctrine supports them.
I would not suggest using this because I don't know the affects this change has on the project as a whole, but I have found that changing that specific line...
$identifierFieldName = $rootClass->getSingleIdentifierFieldName();
to...
if ($rootClass->isIdentifierComposite) {
$identifierFieldName = $rootClass->getIdentifierFieldNames()[0];
} else {
$identifierFieldName = $rootClass->getSingleIdentifierFieldName();
}
in the files LimitSubQuery.php, CountWalker.php, and WhereInWalker.php will set the main identifier as the first identifier of a composite key. This change will allow for my project to display the results of an entity with a composite key, but I am not going to use it because I do not know how it will affect Doctrine's functionality as a whole. Again, probably extremely dangerous to use so I don't suggest it. Just wanted to share what I found.
@arviteri
You get only first key.
Result is can be wrong.
@Ocramius Do you know reason why CountWalker not work with composite?
Mostly because we can't construct an IN() condition with a composite PK.
Closing as can't fix.
@Ocramius my question was about CountWalker.
CountWalker is not have IN condition, your answer it is for WhereInWalker.