Skip to content

Commit b483bd6

Browse files
committed
fix: sqlserver rowversion export type
1 parent 6d8bdc1 commit b483bd6

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

dbptk-modules/dbptk-module-jdbc/src/main/java/com/databasepreservation/modules/jdbc/in/JDBCImportModule.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,22 @@ protected Cell rawToCellSimpleTypeBinary(String id, String columnName, Type cell
19451945
if (cellType instanceof SimpleTypeBinary && ((SimpleTypeBinary) cellType).isOutsideDatabase()) {
19461946
cell = new SimpleCell(id, rawData.getString(columnName));
19471947
} else {
1948+
String originalTypeName = cellType.getOriginalTypeName();
1949+
if (originalTypeName.contains("timestamp") || originalTypeName.contains("rowversion")) {
1950+
StringBuilder hexString = new StringBuilder();
1951+
byte[] rowVersion = rawData.getBytes(columnName);
1952+
1953+
if (rowVersion == null || rowVersion.length == 0){
1954+
return new NullCell(id);
1955+
}
1956+
else {
1957+
for (byte b : rowVersion) {
1958+
hexString.append(String.format("%02X", b));
1959+
}
1960+
return new SimpleCell(id, hexString.toString());
1961+
}
1962+
}
1963+
19481964
Blob blob = rawData.getBlob(columnName);
19491965
if (blob != null && !rawData.wasNull()) {
19501966
cell = new BinaryCell(id, blob);

dbptk-modules/dbptk-module-sql-server/src/main/java/com/databasepreservation/modules/sqlserver/in/SQLServerDatatypeImporter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ protected Type getLongVarbinaryType(String typeName, int columnSize, int decimal
3131

3232
@Override
3333
protected Type getBinaryType(String typeName, int columnSize, int decimalDigits, int numPrecRadix) {
34-
if (typeName.equalsIgnoreCase("timestamp") || typeName.equalsIgnoreCase("rowversion")) {
35-
return getVarcharType(typeName, columnSize, decimalDigits, numPrecRadix);
34+
if (typeName.contains("timestamp") || typeName.contains("rowversion")) {
35+
return super.getBinaryType(typeName, 8, decimalDigits, numPrecRadix);
3636
}
3737
return super.getBinaryType(typeName, columnSize, decimalDigits, numPrecRadix);
3838
}

0 commit comments

Comments
 (0)