Skip to content

Commit

Permalink
Merge pull request #454 from data-integrations/fix/numeric_precision_fix
Browse files Browse the repository at this point in the history
[PLUGIN-1680] numeric_precision_fix
  • Loading branch information
Shubhangi-cs authored Sep 14, 2023
2 parents 32f1f8e + 1f3f735 commit 3cc6cbf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public void write(PreparedStatement stmt) throws SQLException {
}
}

private Schema getNonNullableSchema(Schema.Field field) {
protected Schema getNonNullableSchema(Schema.Field field) {
Schema schema = field.getSchema();
if (field.getSchema().isNullable()) {
schema = field.getSchema().getNonNullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private Object createPGobject(String type, String value, ClassLoader classLoader
protected void writeToDB(PreparedStatement stmt, Schema.Field field, int fieldIndex) throws SQLException {
int sqlIndex = fieldIndex + 1;
ColumnType columnType = columnTypes.get(fieldIndex);
Schema fieldSchema = getNonNullableSchema(field);
if (PostgresSchemaReader.STRING_MAPPED_POSTGRES_TYPES_NAMES.contains(columnType.getTypeName()) ||
PostgresSchemaReader.STRING_MAPPED_POSTGRES_TYPES.contains(columnType.getType())) {
stmt.setObject(sqlIndex, createPGobject(columnType.getTypeName(),
Expand All @@ -114,7 +115,7 @@ protected void writeToDB(PreparedStatement stmt, Schema.Field field, int fieldIn
return;
}
if (columnType.getType() == Types.NUMERIC && record.get(field.getName()) != null &&
field.getSchema().getType() == Schema.Type.STRING) {
fieldSchema.getType() == Schema.Type.STRING) {
stmt.setBigDecimal(sqlIndex, new BigDecimal((String) record.get(field.getName())));
return;
}
Expand Down

0 comments on commit 3cc6cbf

Please sign in to comment.