Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
public class RowReader<C, R> implements Flow.Subscriber<Row>, Function<oracle.jdbc.OracleRow, Row> {

private static final Logger LOG = LoggerFactory.getLogger(RowReader.class);
private static final String byteArrayClassName = byte[].class.getName();

private final ContextInternal context;
private final List<String> types;
Expand Down Expand Up @@ -187,6 +188,11 @@ private static Row transform(List<String> ors, RowDesc desc, oracle.jdbc.OracleR

private static Class<?> getType(String cn) {
try {
// Oracle will return "[B" as class name for byte[], I don't know why the class loader is not able to load this
// So let's return the correct class in this case
if (cn.equals(byteArrayClassName)) {
return byte[].class;
}
return OraclePreparedQueryCommand.class.getClassLoader().loadClass(cn);
} catch (ClassNotFoundException e) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ private <T> void testDecode(TestContext ctx, String columnName, JDBCType jdbcTyp
}));
}

private void testDecodeUsingStream(TestContext ctx, String columnName, JDBCType jdbcType, Buffer expected) {
pool.getConnection().onComplete(ctx.asyncAssertSuccess(conn -> {
conn.prepare("SELECT " + columnName + " FROM binary_data_types WHERE id = 1")
.onComplete(ctx.asyncAssertSuccess(preparedStatement -> {
preparedStatement.cursor().read(10).onComplete(ctx.asyncAssertSuccess(result -> {
ctx.assertEquals(1, result.size());
Row row = result.iterator().next();
ctx.assertEquals(expected, row.get(Buffer.class, 0));
ctx.assertEquals(expected, row.get(Buffer.class, columnName));
ColumnDescriptor columnDescriptor = result.columnDescriptors().get(0);
ctx.assertEquals(jdbcType, columnDescriptor.jdbcType());
ctx.assertNotNull(columnDescriptor);
}));
}));
}));
}

@Test
public void testDecodeRawUsingStream(TestContext ctx) {
testDecodeUsingStream(ctx, "test_raw", JDBCType.VARBINARY, Buffer.buffer("See you space cowboy..."));
}

@Test
public void testEncodeNull(TestContext ctx) {
pool
Expand Down