cosmosdb-server icon indicating copy to clipboard operation
cosmosdb-server copied to clipboard

Check partition header when querying documents

Open tony-kennards opened this issue 4 years ago • 1 comments

When we specify PartitionKey in QueryRequestOptions in c# sdk, it does not require the query string contains partition key condition. Instead, it sends the http header "x-ms-documentdb-partitionkey".

using var query = _container.GetItemQueryIterator<ProductInCosmos>(
                "SELECT * FROM c WHERE c.age < 10",
                requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Student") });

This PR is to check http header when querying documents. If the partition key value is provided in header, do not return 400

tony-kennards avatar Aug 27 '21 01:08 tony-kennards

Thank you for the PR, it makes sense but additionally seems like we need to use the partition value for filtering as well?

For example, SELECT * FROM c WHERE c.age < 10 with the partition key Student should work like:

SELECT * FROM c WHERE c.age < 10 AND c.type = 'Student'

Need to investigate how real cosmos db works actually 🤔

nkzawa avatar Aug 30 '21 08:08 nkzawa