Skip to content

Commit 4e38af0

Browse files
authored
Merge pull request #681 from daniel-skovenborg/fix-null-approx-numeric-postgres
Fixed crash on null approx. numerics in PostgreSQL
2 parents 6eafb2b + 3c8d9bc commit 4e38af0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

dbptk-modules/dbptk-module-postgresql/src/main/java/com/databasepreservation/modules/postgresql/in/PostgreSQLJDBCImportModule.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,11 @@ public Set<String> getIgnoredExportedSchemas() {
434434
@Override
435435
protected Cell rawToCellSimpleTypeNumericApproximate(String id, String columnName, Type cellType, ResultSet rawData)
436436
throws SQLException {
437-
Cell cell = null;
438-
if ("MONEY".equalsIgnoreCase(cellType.getOriginalTypeName())) {
437+
Cell cell;
438+
if (rawData.wasNull()) {
439+
cell = new NullCell(id);
440+
441+
} else if ("MONEY".equalsIgnoreCase(cellType.getOriginalTypeName())) {
439442
String data = rawData.getString(columnName);
440443
if (data != null) {
441444
String parts[] = data.split(" ");
@@ -451,10 +454,10 @@ protected Cell rawToCellSimpleTypeNumericApproximate(String id, String columnNam
451454
String value;
452455
if ("float4".equalsIgnoreCase(cellType.getOriginalTypeName())) {
453456
Float f = rawData.getFloat(columnName);
454-
value = rawData.wasNull() ? null : f.toString();
457+
value = f.toString();
455458
} else {
456459
Double d = rawData.getDouble(columnName);
457-
value = rawData.wasNull() ? null : d.toString();
460+
value = d.toString();
458461
}
459462
cell = new SimpleCell(id, value);
460463
}

0 commit comments

Comments
 (0)