Skip to content

Commit 16f2ffc

Browse files
committed
Fix Mongo
1 parent e25c504 commit 16f2ffc

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Database/Adapter/Mongo.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,12 @@ public function find(string $collection, array $queries = [], ?int $limit = 25,
11021102
}
11031103

11041104
// orders
1105+
$hasIdAttribute = false;
11051106
foreach ($orderAttributes as $i => $attribute) {
1107+
if (\in_array($attribute, ['_uid', '_id'])) {
1108+
$hasIdAttribute = true;
1109+
}
1110+
11061111
$attribute = $this->filter($attribute);
11071112
$orderType = $this->filter($orderTypes[$i] ?? Database::ORDER_ASC);
11081113

@@ -1118,7 +1123,9 @@ public function find(string $collection, array $queries = [], ?int $limit = 25,
11181123
$options['sort'][$attribute] = $this->getOrder($orderType);
11191124
}
11201125

1121-
$options['sort']['_id'] = $this->getOrder($cursorDirection === Database::CURSOR_AFTER ? Database::ORDER_ASC : Database::ORDER_DESC);
1126+
if (!$hasIdAttribute) {
1127+
$options['sort']['_id'] = $this->getOrder($cursorDirection === Database::CURSOR_AFTER ? Database::ORDER_ASC : Database::ORDER_DESC);
1128+
}
11221129

11231130
// queries
11241131

0 commit comments

Comments
 (0)