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

Revisit DatabaseMetadata#getProcedures to only apply fallback if original search yield more than one result #32295

Closed
audunmeltzer opened this issue Feb 19, 2024 · 8 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression
Milestone

Comments

@audunmeltzer
Copy link

Affects: \spring-jdbc 6.1.2


Upgrade from spring-jdbc 6.1.1 to 6.1.2 does not support schema name with underscore, ie 'schema_name'. When execute procedure call.

SimpleJdbcCall(dataSource) .withSchemaName("schema_name") .withFunctionName("updateName") .declareParameters( SqlParameter("id", Types.VARCHAR), SqlParameter("name", Types.VARCHAR)) .execute(MapSqlParameterSource(mapOf("id" to id, "name" to newName)))
Exception thrown
org.springframework.dao.InvalidDataAccessApiUsageException: Required input parameter 'RETURN_VALUE' is missing

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 19, 2024
@jhoeller
Copy link
Contributor

@snicoll is this possibly a regression caused by #22725?

@jhoeller jhoeller added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Feb 19, 2024
@snicoll snicoll self-assigned this Feb 20, 2024
@snicoll
Copy link
Member

snicoll commented Feb 20, 2024

Thanks for reporting this and sorry the upgrade broke your use case.

Upgrade from spring-jdbc 6.1.1 to 6.1.2 does not support schema name with underscore, ie 'schema_name'. When execute procedure call.

_ is a special character that means "any character". The related issue that Juergen shared made sure that those special characters are escaped so that the search is against _ and not any character.

It looks like that doesn't work for you but we can't really know why. What database is this? Can you share a small sample we can run ourselves to reproduce the problem as it may be specific to your environment. You can attach a zip here or push the code to a GitHub repository.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Feb 20, 2024
@audunmeltzer
Copy link
Author

I will create a simple project to illustrate the problem

We are using image mcr.microsoft.com/mssql/server:2017

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 20, 2024
@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Feb 20, 2024
@snicoll
Copy link
Member

snicoll commented Feb 20, 2024

Thanks very much. Since you mention an image, adding a Docker compose or similar to setup the database in the sample will be very much appreciated as I suspect this might be key to the issue here.

@audunmeltzer
Copy link
Author

I have created a simple repo that hopefully illustrates our issue, and might help find a soultion
https://github.com/ks-no/spring-jdbc-demo

As described in readme file, I have created different branches witch combines test with different spring-boot versions and schema name with and without underscore '_'. There is one test that calls a procedure that will run or fail on different branches

@snicoll
Copy link
Member

snicoll commented Feb 21, 2024

I've managed to reproduce the problem. @audunmeltzer FYI, the sample made it extra hard as I couldn't find a way to run your test in IntelliJ IDEA. I managed by using "run all tests under package" option.

This seems to be a bug in the JDBC driver that you're using. I've opened microsoft/mssql-jdbc#2336. I'll see if we can offer an escape hatch for this.

@snicoll snicoll changed the title spring-jdbc 6.1.2 does not longer support schema name with underscore Add support for disabling escaping of schema and catalog for JDBC drivers that do not support it Feb 21, 2024
@snicoll snicoll added type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Feb 21, 2024
@snicoll snicoll added this to the 6.1.5 milestone Feb 21, 2024
@snicoll snicoll changed the title Add support for disabling escaping of schema and catalog for JDBC drivers that do not support it Revisit DatabaseMetadata#getProcedures to only apply fallback if original search yield more than one result Feb 21, 2024
@snicoll
Copy link
Member

snicoll commented Feb 21, 2024

I've made the fix for the original issue a bit more lenient, with the exact same call as before and a fallback on escaping only if more than one procedures/functions are found. This should prevent the fallback from happening from the vast majority of cases and account for drivers that do not handle escaping consistently.

@audunmeltzer
Copy link
Author

Perfect!
Thank you so much for your time and help

Kind regards
Audun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants