This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.54k
stars
2.76k
forks
source link
continuation_token populated even when end of data pages is reached if total pages is divisible by page_zize/max_rows param #32343
Describe the bug
When paging through a Cosmos DB container using by_page(continuation_token), if the total number of pages is evenly divisible by passed max_item_count parameter (e.g., container has 9 items, max_item_count is set to 1 or 3), the continuation_token attribute is set for the last page of data (e.g., for a 9 item container with max_item_count set to 3, the second call passing a continuation_token which is the 3rd page of data).
To Reproduce
using code similar to the code below:
query option "max_item_count" set to 3; the container being queried has 9 items
first call to by_page(), no page_continuation/continuation_token passed: 3 items returned; the continuation_token attribute is populated as expected with the token for the next/2nd page
second call to by_page(page_continuation) where page_continuation is the continuation_token from the first call: 3 items returned; the continuation_token attribute is populated as expected with the token for the next/3rd page
third call to by_page(page_continuation) where page_continuation is the continuation_token from the second call: 3 items returned; the continuation_token attribute is populated; this is not expected;
if a fourth call is made using the continuation_token populated by the third call, the call to next() throws an exception with no error message. this isn't surprising since the token is invalid.
Expected behavior
when the end of pages are reached, the continuation_token attribute should not populated.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
seems to work properly if the number of items in the container is not evenly divisible by the value of "max_item_count" e.g., container has 9 items, max_item_count = 4. On the third call to by_page(page_continuation), the continuation_token is not populated.
Describe the bug When paging through a Cosmos DB container using by_page(continuation_token), if the total number of pages is evenly divisible by passed max_item_count parameter (e.g., container has 9 items, max_item_count is set to 1 or 3), the continuation_token attribute is set for the last page of data (e.g., for a 9 item container with max_item_count set to 3, the second call passing a continuation_token which is the 3rd page of data).
To Reproduce using code similar to the code below:
Expected behavior when the end of pages are reached, the continuation_token attribute should not populated.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context seems to work properly if the number of items in the container is not evenly divisible by the value of "max_item_count" e.g., container has 9 items, max_item_count = 4. On the third call to by_page(page_continuation), the continuation_token is not populated.