Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewListEntitiesPager fix #22469

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/data/aztables/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Breaking Changes

### Bugs Fixed
* Fixed an issue that could cause `Client.NewListEntitiesPager` to skip pages in some cases.

### Other Changes

Expand Down
15 changes: 5 additions & 10 deletions sdk/data/aztables/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,16 @@ func (t *Client) NewListEntitiesPager(listOptions *ListEntitiesOptions) *runtime
}
return runtime.NewPager(runtime.PagingHandler[ListEntitiesResponse]{
More: func(page ListEntitiesResponse) bool {
if page.NextPartitionKey == nil || len(*page.NextPartitionKey) == 0 || page.NextRowKey == nil || len(*page.NextRowKey) == 0 {
return false
}
return true
// if there are no continuation header values, there are no more pages
// https://learn.microsoft.com/rest/api/storageservices/Query-Timeout-and-Pagination
return !((page.NextPartitionKey == nil || len(*page.NextPartitionKey) == 0) && (page.NextRowKey == nil || len(*page.NextRowKey) == 0))
},
Fetcher: func(ctx context.Context, page *ListEntitiesResponse) (ListEntitiesResponse, error) {
var partKey *string
var rowKey *string
if page != nil {
if page.NextPartitionKey != nil {
partKey = page.NextPartitionKey
}
if page.NextRowKey != nil {
rowKey = page.NextRowKey
}
partKey = page.NextPartitionKey
rowKey = page.NextRowKey
} else {
partKey = listOptions.NextPartitionKey
rowKey = listOptions.NextRowKey
Expand Down
4 changes: 1 addition & 3 deletions sdk/data/aztables/service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ func (t *ServiceClient) NewListTablesPager(listOptions *ListTablesOptions) *runt
Fetcher: func(ctx context.Context, page *ListTablesResponse) (ListTablesResponse, error) {
var tableName *string
if page != nil {
if page.NextTableName != nil {
tableName = page.NextTableName
}
tableName = page.NextTableName
} else {
tableName = listOptions.NextTableName
}
Expand Down