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

SQLServerBulkCopy doesn't check BigDecimal scale #230

Closed
Arthurm1 opened this issue Apr 3, 2017 · 3 comments
Closed

SQLServerBulkCopy doesn't check BigDecimal scale #230

Arthurm1 opened this issue Apr 3, 2017 · 3 comments
Assignees
Projects
Milestone

Comments

@Arthurm1
Copy link

Arthurm1 commented Apr 3, 2017

When using SQLServerBulkCopy to import a BigDecimal into a Numeric column the scale isn't checked.

If the column metadata is defined as a Decimal(10, 4) and then new BigDecimal("1").setScale(2, RoundingMode.HALF_UP) is passed the table will end up with a value of 0.01 instead of 1.0

I think it would be safer if the IOBuffer.writeBigDecimal was passed bulkScale by the SQLServerBulkCopy.writeColumnToTdsWriter method and then threw an exception when the bigDecimalVal.scale() differed from bulkScale

@Suraiya-Hameed Suraiya-Hameed self-assigned this Apr 3, 2017
@Suraiya-Hameed
Copy link
Contributor

Yes, using bulkScale value in IOBuffer#writeBigDecimal is the best option.
Thanks @Arthurm1! I will submit a fix.

@Suraiya-Hameed
Copy link
Contributor

Suraiya-Hameed commented Apr 5, 2017

@Arthurm1 can you review PR #251?

@v-nisidh v-nisidh added the Work in Progress The pull request is a work in progress label Apr 11, 2017
@v-nisidh v-nisidh removed the Work in Progress The pull request is a work in progress label Apr 12, 2017
@Suraiya-Hameed
Copy link
Contributor

Closing this issue with fix #251. Thanks again @Arthurm1 !

@lilgreenbird lilgreenbird added this to Closed Issues in MSSQL JDBC Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MSSQL JDBC
  
Closed Issues
Development

No branches or pull requests

3 participants