-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot fetch a NULL literal from a Result #17
Comments
OK, half of the problem is my misunderstanding of reactor's System.out.println((
Flux.from(connectionFactory.create())
.flatMap(c -> c
.createStatement("select cast(null as number) from dual")
.execute())
.flatMap(it -> it.map((r, m) -> new AtomicReference<>(r.get(0, Integer.class))))
.collectList()
.block().get(0)
));
System.out.println((
Flux.from(connectionFactory.create())
.flatMap(c -> c
.createStatement("select cast(null as raw(10)) from dual")
.execute())
.flatMap(it -> it.map((r, m) -> new AtomicReference<>(r.get(0, ByteBuffer.class))))
.collectList()
.block().get(0)
)); But this continues to throw the wrong data type exception: System.out.println((
Flux.from(connectionFactory.create())
.flatMap(c -> c
.createStatement("select null from dual")
.execute())
.flatMap(it -> it.map((r, m) -> new AtomicReference<>(r.get(0, ByteBuffer.class))))
.collectList()
.block().get(0)
)); |
Thanks for your findings! Concerning the Invalid Column Type Error Concerning the NullPointerException: https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.3/README.md#specification Spec Item 2.13: |
Thanks a lot for the feedback, @Michael-A-McMahon
Yes sure. Those things were just artifacts of trying to create a minimal example, in whose attempt I got side tracked... |
Row.get(0, Integer.class) should not throw NPE for a NULL value. This is a JDBC bug. The JDBC spec defines what getInt (and implicitly getObject(int, Class)) should do. While Row is an Oracle extension it should conform to this part of the JDBC spec.
On Mar 29, 2021, at 8:10 AM, Lukas Eder ***@***.******@***.***>> wrote:
I'm trying to fetch the result of a NULL literal without explicit type from an R2DBC result, but I can't seem to do it:
System.out.println((
Flux.from(connectionFactory.create())
.flatMap(c -> c
.createStatement("select null from dual")
.execute())
.flatMap(it -> it.map((r, m) -> r.get(0, Integer.class)))
.collectList()
.block().get(0)
));
This produces:
Exception in thread "main" java.lang.NullPointerException: Row mapping function returned null
at oracle.jdbc.driver.InsensitiveScrollableResultSet$RowPublisher.mapCurrentRow(InsensitiveScrollableResultSet.java:1302)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at oracle.jdbc.driver.PhysicalConnection.lambda$createUserCodeExecutor$10(PhysicalConnection.java:11713)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.PhysicalConnection.lambda$createUserCodeExecutor$11(PhysicalConnection.java:11711)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
at reactor.core.publisher.Mono.block(Mono.java:1703)
When I try fetching binary data:
System.out.println((
Flux.from(connectionFactory.create())
.flatMap(c -> c
.createStatement("select null from dual")
.execute())
.flatMap(it -> it.map((r, m) -> r.get(0, ByteBuffer.class)))
.collectList()
.block().get(0)
));
I'm getting:
Exception in thread "main" java.lang.IllegalArgumentException: java.sql.SQLException: Ungültiger Spaltentyp
at oracle.r2dbc.impl.OracleReactiveJdbcAdapter$OracleJdbcRow.getObject(OracleReactiveJdbcAdapter.java:1193)
at oracle.r2dbc.impl.OracleRowImpl.getByteBuffer(OracleRowImpl.java:272)
at oracle.r2dbc.impl.OracleRowImpl.convertColumnValue(OracleRowImpl.java:245)
at oracle.r2dbc.impl.OracleRowImpl.get(OracleRowImpl.java:137)
at org.jooq.testscripts.R2DBC.lambda$2(R2DBC.java:30)
at oracle.r2dbc.impl.OracleResultImpl$2.lambda$publishRows$0(OracleResultImpl.java:119)
at oracle.r2dbc.impl.OracleReactiveJdbcAdapter.lambda$publishRows$10(OracleReactiveJdbcAdapter.java:698)
at oracle.jdbc.driver.InsensitiveScrollableResultSet$RowPublisher.mapCurrentRow(InsensitiveScrollableResultSet.java:1299)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at oracle.jdbc.driver.PhysicalConnection.lambda$createUserCodeExecutor$10(PhysicalConnection.java:11713)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.PhysicalConnection.lambda$createUserCodeExecutor$11(PhysicalConnection.java:11711)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
at reactor.core.publisher.Mono.block(Mono.java:1703)
at org.jooq.testscripts.R2DBC.main(R2DBC.java:32)
Caused by: java.sql.SQLException: Ungültiger Spaltentyp
at oracle.jdbc.driver.Redirector$99.redirect(Redirector.java:1448)
at oracle.jdbc.driver.Redirector$99.redirect(Redirector.java:1444)
at oracle.jdbc.driver.Representation.getObject(Representation.java:567)
at oracle.jdbc.driver.Accessor.getObject(Accessor.java:1025)
at oracle.jdbc.driver.OracleStatement.getObject(OracleStatement.java:6827)
at oracle.jdbc.driver.InsensitiveScrollableResultSet$RowPublisher$ExpiringRow.getObject(InsensitiveScrollableResultSet.java:1390)
at oracle.r2dbc.impl.OracleReactiveJdbcAdapter$OracleJdbcRow.getObject(OracleReactiveJdbcAdapter.java:1185)
I'm using:
<dependency>
<groupId>com.oracle.database.r2dbc</groupId>
<artifactId>oracle-r2dbc</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-spi</artifactId>
<version>0.9.0.M1</version>
</dependency>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https://github.com/oracle/oracle-r2dbc/issues/17__;!!GqivPVa7Brio!KDQTR9HVwXVjI0rvMrS9Nnkhm0VGihSFRBFo_5QFCbsY6RzgfacNpvzcGV7nzpq0fVI$>, or unsubscribe<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AARZS6KEPRSNAFRVD6ADOIDTGCRALANCNFSM4Z7Y2DQQ__;!!GqivPVa7Brio!KDQTR9HVwXVjI0rvMrS9Nnkhm0VGihSFRBFo_5QFCbsY6RzgfacNpvzcGV7ndFiYR9c$>.
|
Closing this issue as the fix for mapping the null literal to byte[] can only be made in Oracle JDBC, not in Oracle R2DBC. |
Is there a workaround of some way? I'm finding it hard to predictably read create table t (b blob);
insert into t values (null); And then: Class<?> klass = ...?
System.out.println(
Flux.from(cf.create())
.flatMap(c -> c.createStatement("select b from t").execute())
.flatMap(it -> it.map((r, m) -> Optional.ofNullable(r.get(0, klass))))
.collectList()
.block()
); I cannot use
I can use |
@lukaseder, I've opened a new issue to discuss this here: #32 |
Perfect, thanks |
I'm trying to fetch the result of a
NULL
literal without explicit type from an R2DBC result, but I can't seem to do it:This produces:
When I try fetching binary data:
I'm getting:
I'm using:
The text was updated successfully, but these errors were encountered: