Skip to content

Commit

Permalink
Add support for EagerLoader (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
chitoku-k authored May 19, 2022
1 parent 478a5a8 commit fec3c6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ protected function compileSelect(Select $select): Query
->where($this->builder->clause('where'))
->modifier($this->builder->clause('modifier'))
->join($this->builder->clause('join'))
->epilog($this->builder->clause('epilog'));
->epilog($this->builder->clause('epilog'))
->setEagerLoader($this->builder->getEagerLoader());

$this
->compileWhere($builder, $select)
Expand Down Expand Up @@ -146,8 +147,14 @@ protected function compileWhereGroup(ConditionGroup $group): Generator
*/
protected function compileOrderBy(Query $builder, Select $select)
{
$alias = $builder->getRepository()->getAlias();

foreach ($select->orders() as $i => $order) {
$builder->order([$order->column() => $order->order()], $i === 0);
$column = $order->column();
if (strpos($column, '.') === false) {
$column = $alias . '.' . $column;
}
$builder->order([$column => $order->order()], $i === 0);
}
return $this;
}
Expand Down

0 comments on commit fec3c6a

Please sign in to comment.