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

[FIX] PreparedStatement.executeBatch() When the Insert Sql Column Name Case Mismatch, Throws SQLServerException "Unable to retrieve column metadata." #2589

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wooln
Copy link

@wooln wooln commented Jan 21, 2025

fix #2588 [BUG] PreparedStatement.executeBatch() When the Insert Sql Column Name Case Mismatch, Throws SQLServerException "Unable to retrieve column metadata."

@wooln
Copy link
Author

wooln commented Jan 21, 2025

@microsoft-github-policy-service agree

@lilgreenbird
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

@lilgreenbird lilgreenbird left a comment

Choose a reason for hiding this comment

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

fix imports and test cleanup

wooln added 2 commits January 23, 2025 12:55
- Add test case for matching column case in batch execution
- Add test case for mismatched column case in batch execution, expected SQLServerException
- Update column index search to be case-insensitive in SQLServerPreparedStatement
- Remove failing test case in BatchExecutionTest that was checking for specific exception
@wooln wooln force-pushed the bugfix-execute-batch-case-sensitive branch from 719687f to 902ac88 Compare January 23, 2025 04:56
@lilgreenbird
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Collaborator

@David-Engel David-Engel left a comment

Choose a reason for hiding this comment

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

Something to consider:

Does your database use a case-sensitive (like SQL_Latin1_General_CP1_CS_AS) or case-insensitive collation (like SQL_Latin1_General_CP1_CI_AS)?

What happens if you are using a case-sensitive collation and a table like this?

create table [Test1] ([C1] int, [c1] varchar)

@lilgreenbird
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

int columnIndex = -1;
for (int opi = 0; opi < bcOperationColumnList.size(); opi++) {
if (bcOperationColumnList.get(opi).equalsIgnoreCase(c.getColumnName())) {
columnIndex = opi;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
columnIndex = opi;
columnIndex = opi;
break;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
4 participants