Skip to content

Commit 57be9a2

Browse files
scale --> precision (#2269)
1 parent ebf4d78 commit 57be9a2

11 files changed

+56
-56
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -483,18 +483,18 @@ CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold,
483483
void setAccessTokenCallbackClass(String accessTokenCallbackClass);
484484

485485
/**
486-
* Returns the current flag for calcBigDecimalScale.
486+
* Returns the current flag for calcBigDecimalPrecision.
487487
*
488-
* @return calcBigDecimalScale
489-
* Whether calculating big decimal scale from input values is enabled.
488+
* @return calcBigDecimalPrecision
489+
* Whether calculating big decimal precision from input values is enabled.
490490
*/
491-
boolean getCalcBigDecimalScale();
491+
boolean getCalcBigDecimalPrecision();
492492

493493
/**
494-
* Specifies whether to calculate scale from inputted big decimal values.
494+
* Specifies whether to calculate precision from inputted big decimal values.
495495
*
496-
* @param calcBigDecimalScale
497-
* A boolean that indicates if the driver should calculate scale from inputted big decimal values.
496+
* @param calcBigDecimalPrecision
497+
* A boolean that indicates if the driver should calculate precision from inputted big decimal values.
498498
*/
499-
void setCalcBigDecimalScale(boolean calcBigDecimalScale);
499+
void setCalcBigDecimalPrecision(boolean calcBigDecimalPrecision);
500500
}

src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1335,17 +1335,17 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
13351335
void setAccessTokenCallbackClass(String accessTokenCallbackClass);
13361336

13371337
/**
1338-
* Returns value of 'calcBigDecimalScale' from Connection String.
1338+
* Returns value of 'calcBigDecimalPrecision' from Connection String.
13391339
*
1340-
* @param calcBigDecimalScale
1341-
* indicates whether the driver should attempt to calculate scale from inputted big decimal values
1340+
* @param calcBigDecimalPrecision
1341+
* indicates whether the driver should attempt to calculate precision from inputted big decimal values
13421342
*/
1343-
void setCalcBigDecimalScale(boolean calcBigDecimalScale);
1343+
void setCalcBigDecimalPrecision(boolean calcBigDecimalPrecision);
13441344

13451345
/**
1346-
* Sets the value for 'calcBigDecimalScale' property
1346+
* Sets the value for 'calcBigDecimalPrecision' property
13471347
*
1348-
* @return calcBigDecimalScale boolean value
1348+
* @return calcBigDecimalPrecision boolean value
13491349
*/
1350-
boolean getCalcBigDecimalScale();
1350+
boolean getCalcBigDecimalPrecision();
13511351
}

src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ private void setTypeDefinition(DTV dtv) {
592592
param.typeDefinition = SSType.DECIMAL.toString() + "(" + valueLength + "," + scale + ")";
593593
}
594594
} else {
595-
if (con.getCalcBigDecimalScale() && dtv.getJavaType() == JavaType.BIGDECIMAL
595+
if (con.getCalcBigDecimalPrecision() && dtv.getJavaType() == JavaType.BIGDECIMAL
596596
&& null != dtv.getSetterValue()) {
597597
String[] plainValueArray = ((BigDecimal) dtv.getSetterValue()).abs().toPlainString()
598598
.split("\\.");

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -995,16 +995,16 @@ public void setIgnoreOffsetOnDateTimeOffsetConversion(boolean ignoreOffsetOnDate
995995
this.ignoreOffsetOnDateTimeOffsetConversion = ignoreOffsetOnDateTimeOffsetConversion;
996996
}
997997

998-
private boolean calcBigDecimalScale = SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_SCALE.getDefaultValue();
998+
private boolean calcBigDecimalPrecision = SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION.getDefaultValue();
999999

10001000
@Override
1001-
public boolean getCalcBigDecimalScale() {
1002-
return calcBigDecimalScale;
1001+
public boolean getCalcBigDecimalPrecision() {
1002+
return calcBigDecimalPrecision;
10031003
}
10041004

10051005
@Override
1006-
public void setCalcBigDecimalScale(boolean calcBigDecimalScale) {
1007-
this.calcBigDecimalScale = calcBigDecimalScale;
1006+
public void setCalcBigDecimalPrecision(boolean calcBigDecimalPrecision) {
1007+
this.calcBigDecimalPrecision = calcBigDecimalPrecision;
10081008
}
10091009

10101010
/** Session Recovery Object */
@@ -2193,15 +2193,15 @@ Connection connectInternal(Properties propsIn,
21932193
IPAddressPreference.valueOfString(sPropValue).toString());
21942194
}
21952195

2196-
sPropKey = SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_SCALE.toString();
2196+
sPropKey = SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION.toString();
21972197
sPropValue = activeConnectionProperties.getProperty(sPropKey);
21982198
if (null == sPropValue) {
21992199
sPropValue = Boolean
2200-
.toString(SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_SCALE.getDefaultValue());
2200+
.toString(SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION.getDefaultValue());
22012201
activeConnectionProperties.setProperty(sPropKey, sPropValue);
22022202
}
22032203

2204-
calcBigDecimalScale = isBooleanPropertyOn(sPropKey, sPropValue);
2204+
calcBigDecimalPrecision = isBooleanPropertyOn(sPropKey, sPropValue);
22052205

22062206
sPropKey = SQLServerDriverStringProperty.APPLICATION_NAME.toString();
22072207
sPropValue = activeConnectionProperties.getProperty(sPropKey);

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -693,23 +693,23 @@ public void setAccessTokenCallbackClass(String accessTokenCallbackClass) {
693693
}
694694

695695
/**
696-
* Returns the current value for 'calcBigDecimalScale'.
696+
* Returns the current value for 'calcBigDecimalPrecision'.
697697
*
698-
* @return calcBigDecimalScale
698+
* @return calcBigDecimalPrecision
699699
* a boolean
700700
*/
701701
@Override
702-
public boolean getCalcBigDecimalScale() {
703-
return wrappedConnection.getCalcBigDecimalScale();
702+
public boolean getCalcBigDecimalPrecision() {
703+
return wrappedConnection.getCalcBigDecimalPrecision();
704704
}
705705

706706
/**
707-
* Sets the current value of 'calculateBigDecimalScale' for the driver.
707+
* Sets the current value of 'calculateBigDecimalPrecision' for the driver.
708708
*
709-
* @param calcBigDecimalScale
709+
* @param calcBigDecimalPrecision
710710
*/
711711
@Override
712-
public void setCalcBigDecimalScale(boolean calcBigDecimalScale) {
713-
wrappedConnection.setCalcBigDecimalScale(calcBigDecimalScale);
712+
public void setCalcBigDecimalPrecision(boolean calcBigDecimalPrecision) {
713+
wrappedConnection.setCalcBigDecimalPrecision(calcBigDecimalPrecision);
714714
}
715715
}

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -1341,26 +1341,26 @@ public String getAccessTokenCallbackClass() {
13411341
}
13421342

13431343
/**
1344-
* Sets the 'calcBigDecimalScale' setting.
1344+
* Sets the 'calcBigDecimalPrecision' setting.
13451345
*
1346-
* @param calcBigDecimalScale
1347-
* boolean property to have the driver calculate a big decimal's scale from input
1346+
* @param calcBigDecimalPrecision
1347+
* boolean property to have the driver calculate a big decimal's precision from input
13481348
*/
13491349
@Override
1350-
public void setCalcBigDecimalScale(boolean calcBigDecimalScale) {
1351-
setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_SCALE.toString(),
1352-
calcBigDecimalScale);
1350+
public void setCalcBigDecimalPrecision(boolean calcBigDecimalPrecision) {
1351+
setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION.toString(),
1352+
calcBigDecimalPrecision);
13531353
}
13541354

13551355
/**
1356-
* Returns the value for 'calcBigDecimalScale'.
1356+
* Returns the value for 'calcBigDecimalPrecision'.
13571357
*
13581358
* @return computeBigDecimal boolean value
13591359
*/
13601360
@Override
1361-
public boolean getCalcBigDecimalScale() {
1362-
return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_SCALE.toString(),
1363-
SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_SCALE.getDefaultValue());
1361+
public boolean getCalcBigDecimalPrecision() {
1362+
return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION.toString(),
1363+
SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION.getDefaultValue());
13641364
}
13651365

13661366
/**

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ enum SQLServerDriverBooleanProperty {
698698
USE_DEFAULT_JAAS_CONFIG("useDefaultJaasConfig", false),
699699
USE_DEFAULT_GSS_CREDENTIAL("useDefaultGSSCredential", false),
700700
USE_FLEXIBLE_CALLABLE_STATEMENTS("useFlexibleCallableStatements", true),
701-
CALC_BIG_DECIMAL_SCALE("calcBigDecimalScale", false);
701+
CALC_BIG_DECIMAL_PRECISION("calcBigDecimalPrecision", false);
702702

703703
private final String name;
704704
private final boolean defaultValue;
@@ -906,8 +906,8 @@ public final class SQLServerDriver implements java.sql.Driver {
906906
new SQLServerDriverPropertyInfo(SQLServerDriverBooleanProperty.USE_DEFAULT_JAAS_CONFIG.toString(),
907907
Boolean.toString(SQLServerDriverBooleanProperty.USE_DEFAULT_JAAS_CONFIG.getDefaultValue()), false,
908908
TRUE_FALSE),
909-
new SQLServerDriverPropertyInfo(SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_SCALE.toString(),
910-
Boolean.toString(SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_SCALE.getDefaultValue()), false,
909+
new SQLServerDriverPropertyInfo(SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION.toString(),
910+
Boolean.toString(SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION.getDefaultValue()), false,
911911
TRUE_FALSE),
912912
new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.SSL_PROTOCOL.toString(),
913913
SQLServerDriverStringProperty.SSL_PROTOCOL.getDefaultValue(), false,

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ protected Object[][] getContents() {
518518
{"R_unassignableError", "The class specified by the {0} property must be assignable to {1}."},
519519
{"R_InvalidCSVQuotes", "Failed to parse the CSV file, verify that the fields are correctly enclosed in double quotes."},
520520
{"R_TokenRequireUrl", "Token credentials require a URL using the HTTPS protocol scheme."},
521-
{"R_calcBigDecimalScalePropertyDescription", "Indicates whether the driver should calculate scale for big decimal values."},
521+
{"R_calcBigDecimalPrecisionPropertyDescription", "Indicates whether the driver should calculate precision for big decimal values."},
522522
{"R_maxResultBufferPropertyDescription", "Determines maximum amount of bytes that can be read during retrieval of result set"},
523523
{"R_maxResultBufferInvalidSyntax", "Invalid syntax: {0} in maxResultBuffer parameter."},
524524
{"R_maxResultBufferNegativeParameterValue", "MaxResultBuffer must have positive value: {0}."},

src/test/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ public void testDataSource() throws SQLServerException {
208208
ds.setUseFlexibleCallableStatements(booleanPropValue);
209209
assertEquals(booleanPropValue, ds.getUseFlexibleCallableStatements(),
210210
TestResource.getResource("R_valuesAreDifferent"));
211-
ds.setCalcBigDecimalScale(booleanPropValue);
212-
assertEquals(booleanPropValue, ds.getCalcBigDecimalScale(), TestResource.getResource("R_valuesAreDifferent"));
211+
ds.setCalcBigDecimalPrecision(booleanPropValue);
212+
assertEquals(booleanPropValue, ds.getCalcBigDecimalPrecision(), TestResource.getResource("R_valuesAreDifferent"));
213213

214214
ds.setServerCertificate(stringPropValue);
215215
assertEquals(stringPropValue, ds.getServerCertificate(), TestResource.getResource("R_valuesAreDifferent"));

src/test/java/com/microsoft/sqlserver/jdbc/connection/RequestBoundaryMethodsTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ private List<String> getVerifiedMethodNames() {
523523
verifiedMethodNames.add("setAccessTokenCallbackClass");
524524
verifiedMethodNames.add("getUseFlexibleCallableStatements");
525525
verifiedMethodNames.add("setUseFlexibleCallableStatements");
526-
verifiedMethodNames.add("getCalcBigDecimalScale");
527-
verifiedMethodNames.add("setCalcBigDecimalScale");
526+
verifiedMethodNames.add("getCalcBigDecimalPrecision");
527+
verifiedMethodNames.add("setCalcBigDecimalPrecision");
528528
return verifiedMethodNames;
529529
}
530530
}

src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/StatementTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ public void testFailedToResumeTransaction() throws Exception {
14381438
public void testSmallBigDecimalValuesForLossOfPrecision() throws SQLException {
14391439
try (SQLServerConnection con = getConnection();
14401440
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) {
1441-
con.setCalcBigDecimalScale(true);
1441+
con.setCalcBigDecimalPrecision(true);
14421442
double bigDecimalLessThanOne = 0.1235;
14431443
double bigDecimalGreaterThanOne = 1.1235;
14441444
String query = "CREATE PROCEDURE " + procName
@@ -1471,7 +1471,7 @@ public void testSmallBigDecimalValuesForLossOfPrecision() throws SQLException {
14711471
@Test
14721472
public void testLongBigDecimalValuesForLossOfPrecision() throws SQLException {
14731473
try (SQLServerConnection con = getConnection(); Statement stmt = con.createStatement()) {
1474-
con.setCalcBigDecimalScale(true);
1474+
con.setCalcBigDecimalPrecision(true);
14751475
stmt.executeUpdate("CREATE TABLE " + tableName + " (col1 decimal(38,38), col2 decimal(38,37))");
14761476

14771477
// col1 has maximum scale (38) with a leading zero, for a precision of 38. col2 has maximum scale (37) when
@@ -1499,7 +1499,7 @@ public void testLongBigDecimalValuesForLossOfPrecision() throws SQLException {
14991499
@Test
15001500
public void testMathBigDecimalSubtraction() throws SQLException {
15011501
try (SQLServerConnection con = getConnection(); Statement stmt = con.createStatement()) {
1502-
con.setCalcBigDecimalScale(true);
1502+
con.setCalcBigDecimalPrecision(true);
15031503
stmt.executeUpdate("CREATE TABLE " + tableName + " (test_column decimal(10,5))");
15041504
stmt.executeUpdate("INSERT INTO " + tableName + " VALUES(99999.12345)");
15051505
try (PreparedStatement pstmt = con.prepareStatement("SELECT (test_column - ?), "
@@ -1539,7 +1539,7 @@ public void testMathBigDecimalSubtraction() throws SQLException {
15391539
@Test
15401540
public void testMathBigDecimalAddition() throws SQLException {
15411541
try (SQLServerConnection con = getConnection(); Statement stmt = con.createStatement()) {
1542-
con.setCalcBigDecimalScale(true);
1542+
con.setCalcBigDecimalPrecision(true);
15431543
stmt.executeUpdate("CREATE TABLE " + tableName + " (test_column decimal(10,5))");
15441544
stmt.executeUpdate("INSERT INTO " + tableName + " VALUES(99999.12345)");
15451545
try (PreparedStatement pstmt = con.prepareStatement("SELECT (test_column + ?), "
@@ -1579,7 +1579,7 @@ public void testMathBigDecimalAddition() throws SQLException {
15791579
@Test
15801580
public void testMathBigDecimalMultiplication() throws SQLException {
15811581
try (SQLServerConnection con = getConnection(); Statement stmt = con.createStatement()) {
1582-
con.setCalcBigDecimalScale(true);
1582+
con.setCalcBigDecimalPrecision(true);
15831583
stmt.executeUpdate("CREATE TABLE " + tableName + " (test_column decimal(10,5))");
15841584
stmt.executeUpdate("INSERT INTO " + tableName + " VALUES(99999.12345)");
15851585
try (PreparedStatement pstmt = con.prepareStatement("SELECT (test_column * ?), "
@@ -1619,7 +1619,7 @@ public void testMathBigDecimalMultiplication() throws SQLException {
16191619
@Test
16201620
public void testMathBigDecimalDivision() throws SQLException {
16211621
try (SQLServerConnection con = getConnection(); Statement stmt = con.createStatement()) {
1622-
con.setCalcBigDecimalScale(true);
1622+
con.setCalcBigDecimalPrecision(true);
16231623
stmt.executeUpdate("CREATE TABLE " + tableName + " (test_column decimal(10,5))");
16241624
stmt.executeUpdate("INSERT INTO " + tableName + " VALUES(99999.12345)");
16251625
try (PreparedStatement pstmt = con.prepareStatement("select (test_column / ?), "

0 commit comments

Comments
 (0)