Skip to content

Conversation

@Ananya2
Copy link
Contributor

@Ananya2 Ananya2 commented Oct 17, 2025

Fixed issue for PreparedStatement INSERT multiple values update count issue with triggers
This pull request refactors how update counts are determined for INSERT statements in the JDBC driver, ensuring more accurate update counts, especially for PreparedStatement executions involving triggers and multiple value inserts. It removes the subclass override mechanism for TDS token processing and centralizes the logic. Additionally, a new unit test is added to validate correct behavior with triggers and multiple inserts.

Refactoring and logic simplification:

  • Removed the hasUpdateCountTDSTokenForInsertCmd() method and its overrides from both SQLServerStatement and SQLServerPreparedStatement, consolidating the logic for handling update counts for INSERT commands. [1] [2]
  • Updated the condition in the TDS_DONE token processing to directly check for INSERT commands and execution method, rather than relying on the now-removed method.

Testing improvements:

  • Added a new test, testPreparedStatementInsertMultipleValuesWithTrigger, to ensure that PreparedStatement correctly returns the number of inserted rows when using multiple values and triggers, addressing a prior bug where the update count could be incorrect.

@Ananya2 Ananya2 self-assigned this Oct 17, 2025
@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 52.52%. Comparing base (3c17a1a) to head (ff3067d).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...m/microsoft/sqlserver/jdbc/SQLServerStatement.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2817      +/-   ##
============================================
+ Coverage     52.25%   52.52%   +0.27%     
- Complexity     4155     4201      +46     
============================================
  Files           149      149              
  Lines         34366    34500     +134     
  Branches       5733     5778      +45     
============================================
+ Hits          17958    18122     +164     
+ Misses        13914    13912       -2     
+ Partials       2494     2466      -28     

☔ 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.

@Ananya2
Copy link
Contributor Author

Ananya2 commented Oct 30, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Ananya2
Copy link
Contributor Author

Ananya2 commented Oct 30, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Ananya2
Copy link
Contributor Author

Ananya2 commented Oct 30, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Ananya2
Copy link
Contributor Author

Ananya2 commented Oct 30, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Ananya2 Ananya2 merged commit ed649c4 into main Nov 4, 2025
23 of 24 checks passed
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.

5 participants