Skip to content

EscapingParameterSource fallbacks to SqlType UNKNOWN #1681

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

Closed
aumaOne opened this issue Nov 29, 2023 · 3 comments
Closed

EscapingParameterSource fallbacks to SqlType UNKNOWN #1681

aumaOne opened this issue Nov 29, 2023 · 3 comments
Assignees
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@aumaOne
Copy link

aumaOne commented Nov 29, 2023

We're using a custom postgres enum in our application. To support this, we've written a custom converter to set the type for enums to OTHER. That worked great with 6.0.13 but it's broken in 6.1.1 when we're using the enum as query parameter in the repository.

Our configuration:

@Configuration
public class PostgresConfig extends AbstractJdbcConfiguration {
    @Override
    protected List<?> userConverters() {
        return List.of(new PostgresEnumConverter());
    }

    public static class PostgresEnumConverter implements Converter<Enum<?>, JdbcValue> {

        @Override
        public JdbcValue convert(final Enum<?> source) {
            return JdbcValue.of(source, JDBCType.OTHER);
        }
    }
}

After debugging into PreparedStatementCreatorFactory and NamedParameterUtils.buildSqlParameterList the problem seems to be, that the wrapping parameter source org.springframework.data.jdbc.repository.query.EscapingParameterSource doesn't implement the delegating method getSqlType. The underlying MapSqlParameterSource has the correct sql type but isn't used and the factory falls back to UNKNOWN and the statement ended in a SQL Exception
Can't infer the SQL type to use for an instance of com.xxxx. Use setObject() with an explicit Types value to specify the type to use.

this is a blocker for us and we were forced to roll back the update

@aumaOne
Copy link
Author

aumaOne commented Dec 20, 2023

Is there a reason, why the fix isn't merged into the current release 3.2.1 (Branch 3.2.x)?.

This issue still blocks us to upgrade to spring 6.1/spring boot 3.2

@schauder
Copy link
Contributor

schauder commented Jan 3, 2024

Sorry, for that. That was my mistake, and I fixed it.

@aumaOne
Copy link
Author

aumaOne commented Jan 3, 2024

Thanks for your feedback and effort 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

4 participants