Skip to content

Fixed bulk copy for batch inserting null datetime type data when sendTemporalDataTypesAsStringForBulkCopy=false #2702

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

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

Conversation

muskan124947
Copy link
Contributor

@muskan124947 muskan124947 commented Jul 9, 2025

Description

Fixed an issue where inserting null temporal data types (datetime, smalldatetime) would fail when using bulk copy API (useBulkCopyForBatchInsert=true) with sendTemporalDataTypesAsStringForBulkCopy=false.

Background

Extended bulk copy for batch insert support for temporal and money datatypes #2670 - added bulk copy for batch insert support for temporal and money data types.
When sendTemporalDataTypesAsStringForBulkCopy connection property set to true (default), temporal types are sent as varchar strings to work around bulk copy limitations. When set to false, temporal types are sent as their native types.

However, the implementation missed proper null handling when sendTemporalDataTypesAsStringForBulkCopy=false, causing the following error:

java.sql.BatchUpdateException: Data type datetime is not supported in bulk copy. 
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:2259)

Test Coverage

Added comprehensive test cases:

  • testBulkInsertWithNullDataForAllTemporalTypesAndMoney() - validates null handling when sendTemporalDataTypesAsStringForBulkCopy=false

  • testBulkInsertWithNullDataForAllTemporalTypesAndMoneyAsVarchar() - validates null handling when sendTemporalDataTypesAsStringForBulkCopy=true (default)

…sert set to true for dateTime and smalldatetime column
@muskan124947 muskan124947 self-assigned this Jul 9, 2025
@muskan124947 muskan124947 changed the title Added support for bulk inserting null data with useBulkCopyForBatchInsert set to true for dateTime and smalldatetime column Fixed bulk copy for batch inserting null temporal type data when sendTemporalDataTypesAsStringForBulkCopy=false Jul 9, 2025
@muskan124947 muskan124947 changed the title Fixed bulk copy for batch inserting null temporal type data when sendTemporalDataTypesAsStringForBulkCopy=false Fixed bulk copy for batch inserting null datetime type data when sendTemporalDataTypesAsStringForBulkCopy=false Jul 9, 2025
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.61%. Comparing base (87f0553) to head (51997af).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2702      +/-   ##
============================================
+ Coverage     51.50%   51.61%   +0.11%     
- Complexity     4050     4087      +37     
============================================
  Files           149      149              
  Lines         34136    34136              
  Branches       5700     5700              
============================================
+ Hits          17581    17620      +39     
- Misses        14076    14078       +2     
+ Partials       2479     2438      -41     

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

@machavan machavan added this to the 13.1.1 milestone Jul 10, 2025
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.

4 participants