Skip to content

Check partition header when querying documents #73

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tony-kennards
Copy link

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

@nkzawa
Copy link
Contributor

nkzawa commented Aug 30, 2021

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 nkzawa self-requested a review August 30, 2021 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants