Skip to content

Commit 1386ad7

Browse files
author
Gregory Haddow
committed
fix: keyName column may not be present in pagination cursor
1 parent 6e79095 commit 1386ad7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Pagination/Cursor/CursorParser.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ public function __construct(private IdParser $idParser, private string $keyName)
3232
*/
3333
public function encode(LaravelCursor $cursor): string
3434
{
35-
$key = $cursor->parameter($this->keyName);
36-
37-
if ($key) {
35+
try {
36+
$key = $cursor->parameter($this->keyName);
3837
$parameters = $this->withoutPrivate($cursor->toArray());
3938
$parameters[$this->keyName] = $this->idParser->encode($key);
4039
$cursor = new LaravelCursor($parameters, $cursor->pointsToNextItems());
40+
} catch (\UnexpectedValueException $ex) {
41+
// Do nothing as the cursor does not contain the key.
4142
}
4243

4344
return $cursor->encode();

0 commit comments

Comments
 (0)