Commit 6a3db839 authored by Bernhard Schussek's avatar Bernhard Schussek

Made ordering resilient against wrong field names

parent 9a66e08a
......@@ -773,8 +773,13 @@ abstract class ORMRepository extends EntityRepository implements EditableReposit
protected function addOrderByCriteria(QueryBuilder $qb, string $alias, Order $order): void
{
// TODO could we just order by the offset if there is one?
$classMetadata = $this->getClassMetadata();
foreach ($order->getDirections() as $fieldName => $direction) {
if (!$classMetadata->hasField($fieldName)) {
continue;
}
$qb->addOrderBy(
sprintf('%s.%s', $alias, $fieldName),
$direction
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment