Skip to content

Commit 6979126

Browse files
committed
Fix decimal precision shift size
1 parent 2703d70 commit 6979126

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

jdbc/src/main/java/tech/ydb/jdbc/impl/YdbTypes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ public static Type findType(Object obj, int sqlType) {
136136

137137
private Type findTypeImpl(Object obj, int sqlType) {
138138
if ((sqlType & YdbConst.SQL_KIND_DECIMAL) != 0) {
139-
int precision = ((sqlType - YdbConst.SQL_KIND_DECIMAL) >> 5);
140-
int scale = ((sqlType - YdbConst.SQL_KIND_DECIMAL) & 0b11111);
139+
int precision = ((sqlType - YdbConst.SQL_KIND_DECIMAL) >> 6);
140+
int scale = ((sqlType - YdbConst.SQL_KIND_DECIMAL) & 0b111111);
141141
if (precision > 0 && precision < 36 && scale >= 0 && scale <= precision) {
142142
return DecimalType.of(precision, scale);
143143
}

jdbc/src/test/java/tech/ydb/jdbc/impl/YdbPreparedStatementTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private int ydbType(PrimitiveType type) {
227227
}
228228

229229
private int ydbType(DecimalType type) {
230-
return YdbConst.SQL_KIND_DECIMAL + (type.getPrecision() << 5) + type.getScale();
230+
return YdbConst.SQL_KIND_DECIMAL + (type.getPrecision() << 6) + type.getScale();
231231
}
232232

233233
private void fillRowValues(PreparedStatement statement, int id, boolean castingSupported) throws SQLException {

0 commit comments

Comments
 (0)