Skip to content

Commit

Permalink
fix single order-by
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Apr 5, 2024
1 parent ffd2a6f commit 8f083aa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,23 @@ private function getCriteria(

foreach ($properties as $property) {
if ($i === 0) {
if (\count($properties) === 1) {
if ($property['order'] === Order::Ascending) {
$expressions[] = Criteria::expr()->gt(
$property['property'],
$property['value']
);
} else {
$expressions[] = Criteria::expr()->lt(
$property['property'],
$property['value']
);
}

$i++;
continue;
}

if ($property['order'] === Order::Ascending) {
$expressions[] = Criteria::expr()->gte(
$property['property'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,31 @@ private function getQueryBuilder(

foreach ($properties as $property) {
if ($i === 0) {
if (\count($properties) === 1) {
if ($property['order'] === 'ASC') {
$expressions[] = $queryBuilder->expr()->gt(
$property['property'],
":rekapager_where_{$z}"
);
} else {
$expressions[] = $queryBuilder->expr()->lt(
$property['property'],
":rekapager_where_{$z}"
);
}

$queryBuilder->setParameter(
"rekapager_where_{$z}",
$property['value'],
// @phpstan-ignore-next-line
$this->getType($property['property'])
);

$i++;
continue;
}


if ($property['order'] === 'ASC') {
$expressions[] = $queryBuilder->expr()->gte(
$property['property'],
Expand Down

0 comments on commit 8f083aa

Please sign in to comment.