Skip to content

Commit b1edeca

Browse files
feat: ydb jdbc codec decimal (22,9) (31,9) (35,9)
1 parent f8253da commit b1edeca

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package tech.ydb.jdbc;
2+
3+
/**
4+
* @author Kirill Kurdyukov
5+
*/
6+
public class YdbJdbcCode {
7+
8+
private YdbJdbcCode() {
9+
}
10+
11+
public static final int DECIMAL_22_9 = 10024;
12+
13+
public static final int DECIMAL_31_9 = 10025;
14+
15+
public static final int DECIMAL_35_9 = 10026;
16+
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.grpc.netty.shaded.io.netty.util.collection.IntObjectMap;
2020

2121
import tech.ydb.jdbc.YdbConst;
22+
import tech.ydb.jdbc.YdbJdbcCode;
2223
import tech.ydb.table.values.DecimalType;
2324
import tech.ydb.table.values.DecimalValue;
2425
import tech.ydb.table.values.PrimitiveType;
@@ -37,11 +38,15 @@ public class YdbTypes {
3738
private YdbTypes() {
3839
typeBySqlType = new IntObjectHashMap<>(18 + PrimitiveType.values().length);
3940

40-
// Store custom type ids to use it for PrepaparedStatement.setObject
41-
for (PrimitiveType type: PrimitiveType.values()) {
41+
// Store custom type ids to use it for PreparedStatement.setObject
42+
for (PrimitiveType type : PrimitiveType.values()) {
4243
typeBySqlType.put(YdbConst.SQL_KIND_PRIMITIVE + type.ordinal(), type);
4344
}
4445

46+
typeBySqlType.put(YdbJdbcCode.DECIMAL_22_9, DecimalType.of(22, 9));
47+
typeBySqlType.put(YdbJdbcCode.DECIMAL_31_9, DecimalType.of(31, 9));
48+
typeBySqlType.put(YdbJdbcCode.DECIMAL_35_9, DecimalType.of(35, 9));
49+
4550
typeBySqlType.put(Types.VARCHAR, PrimitiveType.Text);
4651
typeBySqlType.put(Types.BIGINT, PrimitiveType.Int64);
4752
typeBySqlType.put(Types.TINYINT, PrimitiveType.Int8);

0 commit comments

Comments
 (0)