-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Implement EF.Functions.JsonExists translation for SQL Server (#31136) #37470
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
Implement EF.Functions.JsonExists translation for SQL Server (#31136) #37470
Conversation
|
@dotnet-policy-service agree |
roji
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this @kimjaejung96. See below for some minor comments, but the bigger issue here is what this actually will be used for. As this PR is, we would notably not support complex/owned JSON documents (i.e. with ToJson()). I'm not sure whether that's an important scenario, since JSON columns mapped to .NET types to via ToJson() presumably have a very fixed schema, and dynamic-like JSON_EXISTS() wouldn't necessarily be very useful on them (though maybe if the schema evolves).
As this PR is, it seems this would only work for JSON columns that the user maps to .NET string; I'm not sure how many people actually do this.
So what exact usage scenario are you targeting here?
src/EFCore.SqlServer/Query/Internal/Translators/SqlServerJsonFunctionTranslator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/Translators/SqlServerJsonFunctionTranslator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/Translators/SqlServerJsonFunctionTranslator.cs
Outdated
Show resolved
Hide resolved
test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs
Outdated
Show resolved
Hide resolved
test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalDbFunctionsExtensions.cs
Outdated
Show resolved
Hide resolved
ed1e702 to
427f675
Compare
- Use primary constructor in SqlServerJsonFunctionTranslator - Use expression-bodied method with ternary operator - Use trimming-friendly method matching (name + declaring type instead of reflection) - Remove [NotParameterized] from path parameter - Remove RelationalDbFunctionsTest.cs (throw tests not useful) - Replace literal-only test with column-based test (JsonExists_with_column)
|
Thanks for the review @roji. You're right that For example:
In these cases, we simply store them as strings but still need to filter at the DB level using I've also addressed your other feedback (primary constructors, removing reflection, and updating tests). |
|
@kimjaejung96 thanks for making the requested changes. I reviewed this more deeply, and for this to be complete, it was lacking the following:
Since there's quite a bit of work here and it requires some familiarity, I've gone ahead and submitted #37477 which implements all of the above - take a look. Your work here is much appreciated and helped trigger #37477 - thanks again! |
Note: I'm submitting this PR proactively because the previous attempts (#30010) appear to be inactive for a long time. I wanted to help move this forward.