Skip to content

Conversation

@kitaisreal
Copy link
Contributor

Motivation #13874

Current implementation steps

  1. Getting identifierQuoteString to use for escaping from dataBaseMetadata in GenericTableMetadataProvider http://docs.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getIdentifierQuoteString%28%29.
  2. Added property usingEscaping in SimpleJdbcInsert and logic related to handling it in TableMetadataContext.
  3. Updated tests.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 18, 2019
@Dretch
Copy link

Dretch commented Dec 16, 2019

This is awesome, thank you very much!

@foldvari
Copy link

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] ).

@manicmonkey
Copy link

@sbrannen you recently made changes in this area - can you comment on the viability of this PR?

@rstoyanchev rstoyanchev added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Nov 10, 2021
@sbrannen sbrannen self-assigned this Aug 31, 2023
@sbrannen sbrannen added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 31, 2023
@sbrannen sbrannen added this to the 6.1.0-RC1 milestone Aug 31, 2023
@sbrannen sbrannen changed the title Support escaping in SimpleJdbcInsert #13874 Support quoted identifiers in SimpleJdbcInsert Aug 31, 2023
Copy link
Member

@sbrannen sbrannen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kitaisreal,

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

@sbrannen sbrannen added the status: waiting-for-feedback We need additional information before we can continue label Aug 31, 2023
@sbrannen
Copy link
Member

sbrannen commented Sep 4, 2023

Do you have time to make the requested changes (consistently referring to "quote identifiers" instead of "using escaping") and rebase on main?

@kitaisreal, you can disregard that. I am taking care of that and other changes locally after merging your PR.

@sbrannen sbrannen removed the status: waiting-for-feedback We need additional information before we can continue label Sep 4, 2023
@sbrannen sbrannen marked this pull request as draft September 4, 2023 16:18
given(databaseMetaData.getIdentifierQuoteString()).willReturn("`");

jdbcInsert.compile();
String expected = "INSERT INTO `S.T` (`F`, `S`) VALUES(?, ?)";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

sbrannen pushed a commit that referenced this pull request Sep 5, 2023
@sbrannen sbrannen closed this in 7dc0653 Sep 5, 2023
@sbrannen
Copy link
Member

sbrannen commented Sep 5, 2023

This has been merged into main in d390347 and revised in 7dc0653. See also 070590c.

Thanks, and congratulations on getting your first PR for the Spring Framework merged! 👍

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: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants