fix: EXPOSED-501 Column.transform() ignores custom setParameter() logic #2214
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.
Description
Summary of the change:
Adds an override for
setParameter()
toColumnWithTransform
class.Detailed description:
Any column type that relies on logic in
setParameter()
to succeed when preparing a statement will fail iftransform()
is used to convert it toColumnWithTransform
. This happens because the delegate's implementation is being ignored by the wrapping class.This behavior can be seen if a custom column type is created that relies on some conversion in
setParameter()
; for example, needing to usePGobject
when setting the parameter type with PostgreSQL.Or, as shown in the test, using
json().transform()
.The same operations that succeed with a standard
json()
will fail withjson().transform()
, throwing something like:This would also fail on H2 because
encodeToByteArray()
is not being reached insidesetParameter()
.Adding
ColumnWithTransform.setParameter()
that uses delegate's function ensures that it is invoked.Type of Change
Please mark the relevant options with an "X":
Affected databases:
Checklist
Related Issues
EXPOSED-501