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

Make discriminator read-only by default #21796

Merged
merged 4 commits into from
Jul 29, 2020

Conversation

ajcvickers
Copy link
Member

Fixes #21154

@ajcvickers ajcvickers changed the base branch from main to release/5.0-preview8 July 26, 2020 21:57
@ajcvickers ajcvickers requested a review from a team July 26, 2020 21:57
Assert.Null(operation.ColumnTypes);
AssertMultidimensionalArray(
operation.Values,
v => Assert.Equal("Dog", v),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. If the discriminator value is not updated the seed entities end up with a null there.

Copy link
Member

@AndriySvyryd AndriySvyryd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeding must be changed to either forcefully update the discriminator value or (less ideal) to recreate the row.

@ajcvickers
Copy link
Member Author

@AndriySvyryd I've been thinking about the force/recreate options. First, for the force option, we would have to assume that the property is really not read-only, even though the metadata says it is. We can't tell if a discriminator was explicitly configured as read-only (without putting more information in the model.) This also requires us to build the mechanism to allow forcing a write in the update pipeline.

Second, if model data updates don't work correctly when a discriminator is marked read-only, then doesn't that mean that they may not work if any property is marked as read-only? Or are the errors here specific to it being a discriminator?

Do you think it's still correct to go the forced update route? Or if we have to fix read-only properties anyway, then should discriminators really be special-cased?

@AndriySvyryd
Copy link
Member

Second, if model data updates don't work correctly when a discriminator is marked read-only, then doesn't that mean that they may not work if any property is marked as read-only? Or are the errors here specific to it being a discriminator?

So far we've assumed that readonly properties would be store generated. Instead we can check and if they aren't then we'll recreate the row.

Do you think it's still correct to go the forced update route? Or if we have to fix read-only properties anyway, then should discriminators really be special-cased?

I don't think it's correct, but it will be a better experience in most cases. However I don't feel strongly.

@AndriySvyryd
Copy link
Member

I've convinced myself that recreating the row is fine as there's still the workaround of configuring the discriminator as writable just while creating the migrations

@ajcvickers
Copy link
Member Author

@AndriySvyryd Would appreciate if you can take this over. Doesn't need to go into preview 8 at this point.

@AndriySvyryd AndriySvyryd self-assigned this Jul 29, 2020
Copy link
Member Author

@ajcvickers ajcvickers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@AndriySvyryd AndriySvyryd merged commit f3f7551 into release/5.0-preview8 Jul 29, 2020
@AndriySvyryd AndriySvyryd deleted the CantTouchThis0726 branch July 29, 2020 20:53
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.

Discriminator should be read-only
3 participants