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: Switch the default discriminator property to $type #34269

Closed
roji opened this issue Jul 22, 2024 · 0 comments · Fixed by #34340
Closed

Cosmos: Switch the default discriminator property to $type #34269

roji opened this issue Jul 22, 2024 · 0 comments · Fixed by #34340
Labels
area-cosmos area-model-building breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Jul 22, 2024

Our current discriminator property in JSON is called Discriminator; but an emerging semi-standard is for $type to be used as the discriminator property (e.g. S.T.Json's polymorphism support); aligning with that would increase the interoperability of documents produced by default by EF with other JSON tools. Given that we're already introducing lots of breaking changes in the Cosmos provider in 9.0, we should do this one as well.

Notes:

  • The Cosmos LINQ provider does not support inheritancei n any direct way; that is, you can tell it to query for a particular CLR type (which may extend another), but it does not have any concept of a discriminator and does not inject discriminator checks into the queries it generates. It's up to the user to do that manually if they desire.
  • Confirm with the Cosmos team that this all makes sense from their perspective (and i.e. doesn't conflict with future plans for their own LINQ provider or whatever).
  • Note that we have two discriminator concepts: one to identify the concrete type in a hierarchy (our regular concept), and another root-only discriminator for when it's integrated into the JSON id property; this is to allow using ReadItem for that scenario (i.e. so that we don't need to know the precise concrete type in order to construct the JSON ID property for ReadItem). The $type discriminator property discussed in this issue should most likely always contain the regular, concrete discriminator value only.
@roji roji added this to the 9.0.0 milestone Jul 22, 2024
ajcvickers added a commit that referenced this issue Aug 2, 2024
…o "$type"

Fixes #34269

Use the following to revert back to the old behavior:

```C#
modelBuilder.HasEmbeddedDiscriminatorName("Discriminator");
```
ajcvickers added a commit that referenced this issue Aug 2, 2024
…o "$type"

Fixes #34269

Use the following to revert back to the old behavior:

```C#
modelBuilder.HasEmbeddedDiscriminatorName("Discriminator");
```
ajcvickers added a commit that referenced this issue Aug 2, 2024
…o "$type"

Fixes #34269

Use the following to revert back to the old behavior:

```C#
modelBuilder.HasEmbeddedDiscriminatorName("Discriminator");
```
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 2, 2024
ajcvickers added a commit that referenced this issue Aug 2, 2024
…o "$type"

Fixes #34269

Use the following to revert back to the old behavior:

```C#
modelBuilder.HasEmbeddedDiscriminatorName("Discriminator");
```
ajcvickers added a commit that referenced this issue Aug 2, 2024
…o "$type"

Fixes #34269

Use the following to revert back to the old behavior:

```C#
modelBuilder.HasEmbeddedDiscriminatorName("Discriminator");
```
ajcvickers added a commit that referenced this issue Aug 5, 2024
…o "$type"

Fixes #34269

Use the following to revert back to the old behavior:

```C#
modelBuilder.HasEmbeddedDiscriminatorName("Discriminator");
```
ajcvickers added a commit that referenced this issue Aug 6, 2024
…o "$type"

Fixes #34269

Use the following to revert back to the old behavior:

```C#
modelBuilder.HasEmbeddedDiscriminatorName("Discriminator");
```
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-rc1 Aug 21, 2024
@ajcvickers ajcvickers removed their assignment Aug 31, 2024
@roji roji modified the milestones: 9.0.0-rc1, 9.0.0 Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-cosmos area-model-building breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants