Skip to content

Conversation

@muskan124947
Copy link
Contributor

Issue Description

When using executeBatch() to insert data, if the names of the columns in SQL statement do not match the case (uppercase/lowercase) of the actual column names in the database, the driver throws a BatchUpdateException with the message "Unable to retrieve column metadata."

GitHub Issue : [BUG] PreparedStatement.executeBatch() When the Insert Sql Column Name Case Mismatch, Throws BatchUpdateException "Unable to retrieve column metadata."

Note: This PR incorporates the community-contributed changes from PR: #2589.

wooln added 11 commits April 24, 2025 11:21
- 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
- Add getIsCaseSensitive() method to SQLCollation class
- Update SQLServerPreparedStatement to use case sensitivity information
- Improve performance by avoiding unnecessary case-insensitive comparisons
- Add support for case-sensitive column names in SQLServerBulkBatchInsertRecord
- Update SQLServerBulkRecord to handle case sensitivity in column metadata
- Modify SQLServerPreparedStatement to pass case sensitivity information to batch records
- Add tests for case-sensitive and case-insensitive column name handling in batch execution
- Return false (case-insensitive) if sortOrder is not found
machavan
machavan previously approved these changes Jun 25, 2025
Ananya2
Ananya2 previously approved these changes Jun 25, 2025
@muskan124947 muskan124947 dismissed stale reviews from Ananya2 and machavan via 47788e4 June 25, 2025 10:27
@codecov
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 59.09091% with 9 lines in your changes missing coverage. Please review.

Project coverage is 51.89%. Comparing base (351c2be) to head (47788e4).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
...oft/sqlserver/jdbc/SQLServerPreparedStatement.java 60.00% 3 Missing and 3 partials ⚠️
.../microsoft/sqlserver/jdbc/SQLServerBulkRecord.java 33.33% 0 Missing and 2 partials ⚠️
...ava/com/microsoft/sqlserver/jdbc/SQLCollation.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2695      +/-   ##
============================================
+ Coverage     51.67%   51.89%   +0.21%     
- Complexity     4011     4054      +43     
============================================
  Files           147      147              
  Lines         33759    33828      +69     
  Branches       5640     5655      +15     
============================================
+ Hits          17445    17554     +109     
+ Misses        13861    13820      -41     
- Partials       2453     2454       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@muskan124947 muskan124947 merged commit 6c85e2c into main Jun 26, 2025
19 checks passed
@muskan124947 muskan124947 modified the milestone: 13.1.0 Jun 26, 2025
@muskan124947 muskan124947 deleted the user/muskgupta/execute-batch-case-sensitive branch June 30, 2025 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

7 participants