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

Added nullable property to Json mapped model resulting in errors instead of mapping non existing json property to null #30028

Closed
rvplauborg opened this issue Jan 11, 2023 · 5 comments · Fixed by #30101

Comments

@rvplauborg
Copy link

File a bug

Please see #29219 for context. This issue is precisely described in the comment #29219 (comment) that was added and is related to #29219.

When a new nullable property is added to a model mapped as json, then querying on that should not error, but instead missing json values in the data should just map to null. According to #29219 looks like this was fixed for simple types (string, int, ..) but still does not work for complex types.

Include provider and version information

EF Core version: 7.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0

@ajcvickers
Copy link
Contributor

/cc @maumar

@maumar
Copy link
Contributor

maumar commented Jan 18, 2023

When accessing sub-element within JsonElement in materialization code we use JsonElement.GetProperty. We should use the TryGetProperty instead

@ajcvickers ajcvickers added this to the 7.0.x milestone Jan 19, 2023
@ajcvickers
Copy link
Contributor

Note from triage: bring to Tactics for patching.

maumar added a commit that referenced this issue Jan 20, 2023
…g in errors instead of mapping non existing json property to null

Problem was that we when accessing inner property on a JsonElement we used GetProperty. If property is not present (which should be allowed if we try to access optional navigation) KeyNotFound is thrown.

Fix is to use TryGetProperty instead to gracefully handle this scenario.

Fixes #30028
maumar added a commit that referenced this issue Feb 24, 2023
…g in errors instead of mapping non existing json property to null

Problem was that we when accessing inner property on a JsonElement we used GetProperty. If property is not present (which should be allowed if we try to access optional navigation) KeyNotFound is thrown.

Fix is to use TryGetProperty instead to gracefully handle this scenario.

Fixes #30028
maumar added a commit that referenced this issue Feb 24, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…g in errors instead of mapping non existing json property to null (#30101)

Problem was that we when accessing inner property on a JsonElement we used GetProperty. If property is not present (which should be allowed if we try to access optional navigation) KeyNotFound is thrown.

Fix is to use TryGetProperty instead to gracefully handle this scenario.

Fixes #30028
@maumar maumar reopened this Feb 24, 2023
@maumar
Copy link
Contributor

maumar commented Feb 24, 2023

reopening for potential servicing

maumar added a commit that referenced this issue Feb 24, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…g in errors instead of mapping non existing json property to null

Problem was that we when accessing inner property on a JsonElement we used GetProperty. If property is not present (which should be allowed if we try to access optional navigation) KeyNotFound is thrown.

Fix is to use TryGetProperty instead to gracefully handle this scenario.

Fixes #30028
@ajcvickers ajcvickers modified the milestones: 7.0.x, 7.0.5 Feb 28, 2023
@meichhorn-conet
Copy link

when will v7.0.5 be released?

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