Skip to content

Commit

Permalink
Add support for EagerLoader (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
chitoku-k authored May 19, 2022
1 parent aa2ad68 commit 0fa0b91
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 @@ -111,7 +111,8 @@ protected function compileSelect(Select $select)
->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 @@ -152,8 +153,14 @@ protected function compileWhereGroup(ConditionGroup $group)
*/
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 0fa0b91

Please sign in to comment.