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

Cosmos: Document behavior and pitfalls when documents are missing mapped properties #1712

Closed
divega opened this issue Sep 9, 2019 · 1 comment · Fixed by #1728
Closed
Assignees
Milestone

Comments

@divega
Copy link
Contributor

divega commented Sep 9, 2019

This is the documentation part of the decision recorded at dotnet/efcore#13131 (comment)

The short version is that in a schema-less database like Cosmos DB it is valid for each document in a container to contain completely different set of properties. In an object mapping situation this translates into some of the mapped properties being absent. Cosmos DB provides a function IS_DEFINED() that can be used in queries to test for this situation. Note also that a property not being defined is different (albeit one can argue only slightly) from the value being null.

One common scenario we expect this will happen is when Cosmos DB provider users add properties to classes for which they have already stored instances in the database: The existing instances will be missing those new properties.

@divega
Copy link
Contributor Author

divega commented Sep 9, 2019

Another important aspect of missing properties is that due to limitations on how Cosmos DB indexes work, an ORDER BY on a property can cause document instances that are missing the property to be filtered out from the results.

This was going to be fixed as part of an improvement to index layouts for Cosmos DB, but I am not sure if it is working. It should be easy to test...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants