spring-data-relational icon indicating copy to clipboard operation
spring-data-relational copied to clipboard

GH-2188 - Preserve JDBCType.OTHER for custom converters in string-based queries

Open parazit-IR opened this issue 1 month ago • 0 comments

This PR addresses GH-2188 (Converters with JDBCType.OTHER broken).

Summary

Custom converters that return JdbcValue with JDBCType.OTHER stopped working correctly for string-based queries.
StringBasedJdbcQuery treated JDBCType.OTHER as a special case and did not register its SQL type when binding parameters, so the JDBC driver did not see Types.OTHER anymore.

Changes

  • Update StringBasedJdbcQuery.bindParameters(…) to register the SQL type for all non-null SQLType values, including JDBCType.OTHER, and only fall back to the type-less addValue(name, value) overload when the JDBC type is actually null.
  • Add a regression test to StringBasedJdbcQueryUnitTests that:
    • uses a custom @WritingConverter returning JdbcValue.of(…, JDBCType.OTHER),
    • executes a string-based query method,
    • and asserts that the resulting SqlParameterSource exposes Types.OTHER for the bound parameter.

This restores the behavior for PostgreSQL enum/custom types and other use cases that rely on JDBCType.OTHER in custom converters.

Closes #2188

parazit-IR avatar Dec 06 '25 12:12 parazit-IR