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

feat: ydb jdbc codec decimal (22,9) (31,9) (35,9) #82

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions jdbc/src/main/java/tech/ydb/jdbc/YdbJdbcCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tech.ydb.jdbc;

/**
* @author Kirill Kurdyukov
*/
public class YdbJdbcCode {

private YdbJdbcCode() {
}

public static final int DECIMAL_22_9 = 10024;

public static final int DECIMAL_31_9 = 10025;

public static final int DECIMAL_35_9 = 10026;
}
9 changes: 7 additions & 2 deletions jdbc/src/main/java/tech/ydb/jdbc/impl/YdbTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.grpc.netty.shaded.io.netty.util.collection.IntObjectMap;

import tech.ydb.jdbc.YdbConst;
import tech.ydb.jdbc.YdbJdbcCode;
import tech.ydb.table.values.DecimalType;
import tech.ydb.table.values.DecimalValue;
import tech.ydb.table.values.PrimitiveType;
Expand All @@ -37,11 +38,15 @@ public class YdbTypes {
private YdbTypes() {
typeBySqlType = new IntObjectHashMap<>(18 + PrimitiveType.values().length);

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

typeBySqlType.put(YdbJdbcCode.DECIMAL_22_9, DecimalType.of(22, 9));
typeBySqlType.put(YdbJdbcCode.DECIMAL_31_9, DecimalType.of(31, 9));
typeBySqlType.put(YdbJdbcCode.DECIMAL_35_9, DecimalType.of(35, 9));

typeBySqlType.put(Types.VARCHAR, PrimitiveType.Text);
typeBySqlType.put(Types.BIGINT, PrimitiveType.Int64);
typeBySqlType.put(Types.TINYINT, PrimitiveType.Int8);
Expand Down
Loading