-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Json column fails to materialize only when default interceptor used #30244
Comments
When building JSON entity using a materializer we generate the following materializer initially:
when we then visit the materializer we replace So before we had expression returning |
this was not a problem before, because normally we store the key values in |
…terceptor used Problem was that when we build materializer expression, ValueBufferTryReadValue call that extracts values of keys is typed with key's CLR type. This fails for json as we visit the materializer expression, because calls to ValueBufferTryReadValue are replaced with array accesses to object[] that we store key values in. We should be using ValueBufferTryReadValue<object> when trying to get value for keys, like we do everywhere else, so that after the visitation expression types are correct. Fixes #30244
…terceptor used Problem was that when we build materializer expression, ValueBufferTryReadValue call that extracts values of keys is typed with key's CLR type. This fails for json as we visit the materializer expression, because calls to ValueBufferTryReadValue are replaced with array accesses to object[] that we store key values in. We should be using ValueBufferTryReadValue<object> when trying to get value for keys, like we do everywhere else, so that after the visitation expression types are correct. Fixes #30244
…terceptor used Problem was that when we build materializer expression, ValueBufferTryReadValue call that extracts values of keys is typed with key's CLR type. This fails for json as we visit the materializer expression, because calls to ValueBufferTryReadValue are replaced with array accesses to object[] that we store key values in. We should be using ValueBufferTryReadValue<object> when trying to get value for keys, like we do everywhere else, so that after the visitation expression types are correct. Fixes #30244
…terceptor used (#30403) * Fix to #30244 - Json column fails to materialize only when default interceptor used Problem was that when we build materializer expression, ValueBufferTryReadValue call that extracts values of keys is typed with key's CLR type. This fails for json as we visit the materializer expression, because calls to ValueBufferTryReadValue are replaced with array accesses to object[] that we store key values in. We should be using ValueBufferTryReadValue<object> when trying to get value for keys, like we do everywhere else, so that after the visitation expression types are correct. Fixes #30244 * Move testing to the interceptor tests, which are setup for singleton options
I was trying to implement a materialization interceptor when I came across this issue. The attached project implements the interceptor but just as a pass through. The interceptor doesn't have to do anything to cause the error.
I do receive the same type of error as #29380 but I believe this is different as my Json doesn't use Id.
Attaching project that reproduces the issue. Run dotnet ef database update. Run application and watch it output the values in the json column. Uncomment line 14 in the TestDbContext and run the application again and get the following stack trace...
EF Core version: 7.0.2
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
Operating system: Windows 10 Pro
IDE: Visual Studio 2022 17.4.4
IssueRepro.zip
The text was updated successfully, but these errors were encountered: