Skip to content

Commit

Permalink
[Internal] MigratedFixedCollection: Fixed a NullRef in FeedRangeParti…
Browse files Browse the repository at this point in the history
…tionKey.ToString()
  • Loading branch information
ramarag committed Oct 3, 2022
1 parent caa10f7 commit 84c111f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
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

0 comments on commit 84c111f

Please sign in to comment.