HHH-19202 Fix array_intersects function with array parameters#11677
Closed
JiHunparkkk wants to merge 1 commit intohibernate:mainfrom
Closed
HHH-19202 Fix array_intersects function with array parameters#11677JiHunparkkk wants to merge 1 commit intohibernate:mainfrom
JiHunparkkk wants to merge 1 commit intohibernate:mainfrom
Conversation
Member
|
Thank you @JiHunparkkk, but I don't see a need for the custom argument type resolver - the existing implementation should already infer the parameter type from the entity path expression. #11679 was also opened for this bug, and I think the solution is cleaner - I'll close this one in favor of that. |
Author
|
Thanks for the review and explanation! I see your point, and I agree that the approach in #11679 is cleaner and avoids the need for a custom argument type resolver. Thanks again! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using
array_intersectswith a parameterized array query like:H2 database throws:
JdbcSQLSyntaxErrorException: Unknown data type: "?3"Root Cause
AbstractArrayIntersectsFunctionused a genericStandardFunctionArgumentTypeResolvers.byArgument()which didn't properly infer array types bidirectionallyH2ArrayIntersectsFunctionrendered parameters withaccept(walker)instead ofwalker.render(..., NO_PLAIN_PARAMETER), causing H2'sarray_get()function to receive untyped parametersSolution
ArrayIntersectsArgumentTypeResolverfor bidirectional type inference between the two array argumentsH2ArrayIntersectsFunctionto useSqlAstNodeRenderingMode.NO_PLAIN_PARAMETERwhich renders parameters asCAST(? AS ARRAY_TYPE)instead of plain?Changes
AbstractArrayIntersectsFunction.java- UseArrayIntersectsArgumentTypeResolver.INSTANCEArrayIntersectsArgumentTypeResolver.java- New resolver for bidirectional array type inferenceH2ArrayIntersectsFunction.java- UseNO_PLAIN_PARAMETERrendering mode forarray_get()callsArrayIntersectsTest.java- AddtestArrayParameter()test case"Test
Test case referenced from #9798
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-19202
Please make sure that the following tasks are completed:
Tasks specific to HHH-19202 (Bug):
migration-guide.adocOR check there are no breaking changes