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

Fixes issue with PreparedStatement.setBigDecimal() in the driver when no scale is passed #684

Merged
merged 9 commits into from
May 2, 2018
6 changes: 5 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
Original file line number Diff line number Diff line change
Expand Up @@ -2212,8 +2212,12 @@ void execute(DTV dtv,
BigDecimal bigDecimalValue) throws SQLServerException {
// Rescale the value if necessary
if (null != bigDecimalValue) {
if (null == dtv.getScale())
dtv.setScale((bigDecimalValue.precision()>SQLServerConnection.maxDecimalPrecision ?
SQLServerConnection.maxDecimalPrecision - (bigDecimalValue.precision() - bigDecimalValue.scale()) :
bigDecimalValue.scale()));
Integer inScale = dtv.getScale();
if (null != inScale && inScale != bigDecimalValue.scale())
if (inScale != bigDecimalValue.scale())
bigDecimalValue = bigDecimalValue.setScale(inScale, RoundingMode.DOWN);
}

Expand Down