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
Support quoted identifiers in SimpleJdbcInsert
#24013
Conversation
This is awesome, thank you very much! |
As far as I see this solution does not support cases when the opening and the closing character used for quoting is different. (E.g. MS SQL [identifier] ). |
...-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java
Show resolved
Hide resolved
@sbrannen you recently made changes in this area - can you comment on the viability of this PR? |
SimpleJdbcInsert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, and sorry for taking so long to review this.
Do you have time to make the requested changes (consistently referring to "quote identifiers" instead of "using escaping") and rebase on main
?
If not, just let us know, and we'll take over the PR.
Cheers,
Sam
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java
Show resolved
Hide resolved
@kitaisreal, you can disregard that. I am taking care of that and other changes locally after merging your PR. |
given(databaseMetaData.getIdentifierQuoteString()).willReturn("`"); | ||
|
||
jdbcInsert.compile(); | ||
String expected = "INSERT INTO `S.T` (`F`, `S`) VALUES(?, ?)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String expected = "INSERT INTO `S.T` (`F`, `S`) VALUES(?, ?)"; | |
String expected = "INSERT INTO `S`.`T` (`F`, `S`) VALUES(?, ?)"; |
Just a side note: the schema and table names have to be quoted independently.
I've fixed this in my local branch and added integration tests with H2 to verify it.
Motivation #13874
Current implementation steps
GenericTableMetadataProvider
http://docs.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getIdentifierQuoteString%28%29.SimpleJdbcInsert
and logic related to handling it inTableMetadataContext
.