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

fix: EXPOSED-501 Column.transform() ignores custom setParameter() logic #2214

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

bog-walk
Copy link
Member

Description

Summary of the change:
Adds an override for setParameter() to ColumnWithTransform class.

Detailed description:

  • Why:

Any column type that relies on logic in setParameter() to succeed when preparing a statement will fail if transform() is used to convert it to ColumnWithTransform. 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 use PGobject 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 with json().transform(), throwing something like:

org.postgresql.util.PSQLException: ERROR: column "numbers" is of type json but expression is of type character varying
  Hint: You will need to rewrite or cast the expression.

This would also fail on H2 because encodeToByteArray() is not being reached inside setParameter().

  • How:

Adding ColumnWithTransform.setParameter() that uses delegate's function ensures that it is invoked.


Type of Change

Please mark the relevant options with an "X":

  • Bug fix

Affected databases:

  • All

Checklist

  • Unit tests are in place
  • The build is green (including the Detekt check)
  • All public methods affected by my PR has up to date API docs

Related Issues

EXPOSED-501

Adding transform() to a column with a type that relies on logic in setParameter()
leads to failure because the delegate's function is not invoked by the wrapping
ColumnWithTransform.

This adds an override to ColumnWithTransform that ensures the delegate's
function is entered.
@bog-walk bog-walk requested a review from joc-a August 23, 2024 21:51
@bog-walk bog-walk merged commit 8ca4d02 into main Aug 26, 2024
5 checks passed
@bog-walk bog-walk deleted the bog-walk/fix-transformer-set-parameter branch August 26, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants