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

[release/8.0] Fix to #32972 - The database default created by Migrations for primitive collections mapped to JSON is invalid #33048

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Feb 10, 2024

Port of #33039 and #33050
Fixes #32972

Description
Problem was that when adding new required column to an existing table we always need to provide default value (to fill the values for rows already in the table). For collection of primitives that get map to JSON we should be setting the value to empty JSON collection, i.e. '[]' but we were not doing that.

Customer impact
Incorrect migration generated when new primitive collection property is added to an existing table. Workaround is to manually edit the migration code. This is painful because primitive collections is highly anticipated feature in EF8, and when customers want to incorporate it into their existing projects they get hit by this bug.

How found
Customer reported on 8.

Regression
No, primitive collections are a new feature in 8.

Testing
Multiple tests added.

Risk
Low. Change is straightforward (adding proper hard-coded default value representing empty JSON collection) and we already do something similar for entities mapped to JSON. Added quirk just to be safe.

…ive collections mapped to JSON is invalid

Problem was that when adding new required column to an existing table we always need to provide default value (to fill the values for rows already in the table). For collection of primitives that get map to json we should be setting the value to empty JSON collection, i.e. '[]' but we were not doing that.
@maumar maumar changed the title Fix to #32972 - The database default created by Migrations for primitive collections mapped to JSON is invalid [release/8.0] Fix to #32972 - The database default created by Migrations for primitive collections mapped to JSON is invalid Feb 10, 2024
@maumar maumar requested a review from a team February 10, 2024 01:26
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.

Note that the branch is currently closed

@maumar maumar added this to the 8.0.4 milestone Feb 18, 2024
@maumar maumar merged commit 406121f into release/8.0 Mar 5, 2024
7 checks passed
@maumar maumar deleted the fix32972_80 branch March 5, 2024 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants