Fixes issue with PreparedStatement.setBigDecimal() in the driver when no scale is passed#684
Merged
cheenamalhotra merged 9 commits intomicrosoft:devfrom May 2, 2018
Merged
Conversation
Closed
Codecov Report
@@ Coverage Diff @@
## dev #684 +/- ##
============================================
- Coverage 48.13% 48.13% -0.01%
+ Complexity 2576 2573 -3
============================================
Files 113 113
Lines 26561 26569 +8
Branches 4435 4438 +3
============================================
+ Hits 12786 12789 +3
+ Misses 11647 11642 -5
- Partials 2128 2138 +10
Continue to review full report at Codecov.
|
peterbae
reviewed
Apr 24, 2018
Contributor
peterbae
left a comment
There was a problem hiding this comment.
I would put the if statement at line 2215 in a bracket (we should apply brackets to if statements even if it only has one line).
Otherwise looks good to me. We won't have to worry about the line 2216 turning up negative since SQLServerConnectionmaxDecimalPrecision will always be larger than bigDecimalValue.precision().
ulvii
reviewed
May 1, 2018
| Integer inScale = dtv.getScale(); | ||
| if (null != inScale && inScale != bigDecimalValue.scale()) | ||
| bigDecimalValue = bigDecimalValue.setScale(inScale, RoundingMode.DOWN); | ||
| Integer dtvScale, biScale = bigDecimalValue.scale(); |
Contributor
There was a problem hiding this comment.
Please apply the formatter, otherwise looks good!
peterbae
approved these changes
May 2, 2018
rene-ye
approved these changes
May 2, 2018
ulvii
approved these changes
May 2, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for issue #683.
Issue occurs when BigDecimal value is created from double [
e.g. new BigDecimal(5.55)] or as it is exceeds in Precision than maxAllowedPrecision (38) in SQL Server, and no scale is passed from Client. The driver in this case fails to round off digits and passes BigDecimal value as String, which when received by SQL Server fails with Exception:com.microsoft.sqlserver.jdbc.SQLServerException: Error converting data type nvarchar to decimal.This fix makes sure BigDecimal values passed to SQL Server are within precision limits and scaled accordingly.