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

Comments

Projects
None yet
3 participants
@Arthurm1

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

This comment has been minimized.

Contributor

Suraiya-Hameed commented Apr 3, 2017

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

@Suraiya-Hameed

This comment has been minimized.

Contributor

Suraiya-Hameed commented Apr 5, 2017

@Arthurm1 can you review PR #251?

@Suraiya-Hameed

This comment has been minimized.

Contributor

Suraiya-Hameed commented Apr 21, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment