From 52bb7f08ba3b8f56b7eba3f153ce194cb40ec965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 26 Nov 2024 16:43:06 +0100 Subject: [PATCH] Fix Pagination when token is an array (#1811) --- CHANGELOG.md | 4 ++++ src/Result/BatchGetItemOutput.php | 2 +- src/Result/QueryOutput.php | 2 +- src/Result/ScanOutput.php | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a370d43..90248b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- fix pagination when next token is an array + ## 3.3.0 ### Added diff --git a/src/Result/BatchGetItemOutput.php b/src/Result/BatchGetItemOutput.php index 11237a3..ed57f41 100644 --- a/src/Result/BatchGetItemOutput.php +++ b/src/Result/BatchGetItemOutput.php @@ -83,7 +83,7 @@ public function getConsumedCapacity(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if (null !== $page->unprocessedKeys) { + if ([] !== $page->unprocessedKeys) { $input->setRequestItems($page->unprocessedKeys); $this->registerPrefetch($nextPage = $client->batchGetItem($input)); diff --git a/src/Result/QueryOutput.php b/src/Result/QueryOutput.php index 449e03d..0b0a069 100644 --- a/src/Result/QueryOutput.php +++ b/src/Result/QueryOutput.php @@ -116,7 +116,7 @@ public function getItems(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if (null !== $page->lastEvaluatedKey) { + if ([] !== $page->lastEvaluatedKey) { $input->setExclusiveStartKey($page->lastEvaluatedKey); $this->registerPrefetch($nextPage = $client->query($input)); diff --git a/src/Result/ScanOutput.php b/src/Result/ScanOutput.php index 85d2ca3..90ce249 100644 --- a/src/Result/ScanOutput.php +++ b/src/Result/ScanOutput.php @@ -116,7 +116,7 @@ public function getItems(bool $currentPageOnly = false): iterable $page = $this; while (true) { $page->initialize(); - if (null !== $page->lastEvaluatedKey) { + if ([] !== $page->lastEvaluatedKey) { $input->setExclusiveStartKey($page->lastEvaluatedKey); $this->registerPrefetch($nextPage = $client->scan($input));