feat(db2): preview binary large object columns as hex
This commit is contained in:
2 files changed
+26
No files matched your search
@@ -402,6 +402,10 @@ public final class Db2Agent extends AbstractJdbcAgent {
|
||||
String value = rs.getString(index);
|
||||
return rs.wasNull() ? null : value;
|
||||
}
|
||||
if (sqlType == Types.BLOB || sqlType == Types.BINARY || sqlType == Types.VARBINARY || sqlType == Types.LONGVARBINARY) {
|
||||
byte[] value = rs.getBytes(index);
|
||||
return rs.wasNull() ? null : JdbcExecutor.bytesToHex(value);
|
||||
}
|
||||
Object value = rs.getObject(index);
|
||||
return rs.wasNull() ? null : value == null ? null : value.toString();
|
||||
});
|
||||
|
||||
@@ -70,6 +70,28 @@ class Db2AgentTest extends JdbcFakeExecutionBehaviorTest {
|
||||
assertEquals("long text value", agent.resultValue(resultSet, 1, Types.CLOB));
|
||||
}
|
||||
|
||||
@Test
|
||||
void readsBlobValuesAsHexInsteadOfVendorObjectNames() {
|
||||
Db2Agent agent = new Db2Agent();
|
||||
ResultSet resultSet = proxy(ResultSet.class, new MethodHandler() {
|
||||
@Override
|
||||
public Object handle(Method method, Object[] args) {
|
||||
if ("getBytes".equals(method.getName())) {
|
||||
return new byte[] {(byte) 0x89, 0x50, 0x4e};
|
||||
}
|
||||
if ("wasNull".equals(method.getName())) {
|
||||
return false;
|
||||
}
|
||||
return defaultValue(method.getReturnType());
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals("0x89504e", agent.resultValue(resultSet, 1, Types.BLOB));
|
||||
assertEquals("0x89504e", agent.resultValue(resultSet, 1, Types.BINARY));
|
||||
assertEquals("0x89504e", agent.resultValue(resultSet, 1, Types.VARBINARY));
|
||||
assertEquals("0x89504e", agent.resultValue(resultSet, 1, Types.LONGVARBINARY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listsAllCatalogSchemasWithoutOwnerTypeFiltering() {
|
||||
Db2Agent agent = new Db2Agent();
|
||||
|
||||
Reference in new issue
Block a user