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

FeedRange: Fixes a NullRef in FeedRangePartitionKey.ToString() #3480

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ internal override Task<TResult> AcceptAsync<TResult, TArg>(
TArg argument,
CancellationToken cancellationToken) => visitor.VisitAsync(this, argument, cancellationToken);

public override string ToString() => this.PartitionKey.InternalKey.ToJsonString();
public override string ToString()
{
if (this.PartitionKey.IsNone)
{
return "None";
}

return this.PartitionKey.InternalKey.ToJsonString();
}

internal override TResult Accept<TResult>(IFeedRangeTransformer<TResult> transformer)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,18 @@ public async Task ReadNonPartitionItemAsync()
}
}

//use ReadFeed on fixed container with CosmosContainerSettings.NonePartitionKeyValue.
using (FeedIterator<dynamic> feedIterator = fixedContainer.GetItemQueryIterator<dynamic>(
queryText: null,
requestOptions: new QueryRequestOptions() { MaxItemCount = 10, PartitionKey = Cosmos.PartitionKey.None, }))
{
while (feedIterator.HasMoreResults)
{
FeedResponse<dynamic> readFeedResponse = await feedIterator.ReadNextAsync();
Assert.AreEqual(2, readFeedResponse.Count());
}
}

//Quering items on fixed container with non-none PK.
using (FeedIterator<dynamic> feedIterator = fixedContainer.GetItemQueryIterator<dynamic>(
sql,
Expand All @@ -2539,6 +2551,18 @@ public async Task ReadNonPartitionItemAsync()
}
}

//ReadFeed on on fixed container with non-none PK.
using (FeedIterator<dynamic> feedIterator = fixedContainer.GetItemQueryIterator<dynamic>(
queryText: null,
requestOptions: new QueryRequestOptions() { MaxItemCount = 10, PartitionKey = new Cosmos.PartitionKey(itemWithPK.partitionKey) }))
{
while (feedIterator.HasMoreResults)
{
FeedResponse<dynamic> readFeedResponse = await feedIterator.ReadNextAsync();
Assert.AreEqual(1, readFeedResponse.Count());
}
}

//Deleting item from fixed container with CosmosContainerSettings.NonePartitionKeyValue.
ItemResponse<ToDoActivity> deleteResponseWithoutPk = await fixedContainer.DeleteItemAsync<ToDoActivity>(
partitionKey: Cosmos.PartitionKey.None,
Expand Down