-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Json: error when trying to materialize json entity with nullable property that is null in the json string - should materialize the property as null instead #34293
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
Comments
Entity OrganizationData is required but the JSON element containing it is null I also encountered this problem today public OrganizationData? Organization { get; set; }
Normal operation: There is a bug: |
@roji From what we have observed so far, if you query directly against the table, there is no problem, but if you query against a new dto, there will be a problem. |
The problem is we were incorrectly computing the nullability of json reference - using |
…th nullable property that is null in the json string - should materialize the property as null instead Problem was that when computing nullability of a JSON entity we were using faulty logic - checking if the foreign key is required, rather than if its required dependent. This lead to optional entities being incorrectly marked as required and cause validation error when JSON contained null. Fixes #34293
…th nullable property that is null in the json string - should materialize the property as null instead Problem was that when computing nullability of a JSON entity we were using faulty logic - checking if the foreign key is required, rather than if its required dependent. This lead to optional entities being incorrectly marked as required and cause validation error when JSON contained null. Fixes #34293
#35412 |
@dashiell-zhang this issue has been fixed in the upcoming EF10 - we didn't fix it in time for EF9. |
@maumar Any plan to backport it in EF9 ? It is a blocking point for me. |
@boukenka at the moment we don't plan to port this to EF9, reason being that it's not a regression (scenario also fails on EF8) and relatively few people have hit the issue so far. |
We would also appreciate this being backported to EF9 instead of having to wait for EF10 |
Also facing this problem. The workaround for my use case isn't great. Would also really appreciate a patch into 9 @maumar. Thanks |
A Backport to EFCore 9 would also be appreciated. |
Maybe a regression of #29219
Materializing a JSON entity with
null
property results in an error even if the target model allows null.Expected to materialize the property as null instead.
Entity Definition:
Data
Example Code to show error
Provider and version information
EF Core version:
Microsoft.EntityFrameworkCore v8.0.7
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL v8.0.4
Target framework: .NET 8.0
Operating system: Windows
IDE: Microsoft Visual Studio Community 2022 (64-bit) Version 17.10.4
The text was updated successfully, but these errors were encountered: