Closed cretz closed 7 years ago
Diff for test to replicate:
diff --git a/src/test/java/com/github/pgasync/impl/TransactionTest.java b/src/test/java/com/github/pgasync/impl/TransactionTest.java
index 3d8c3eb..902ec21 100644
--- a/src/test/java/com/github/pgasync/impl/TransactionTest.java
+++ b/src/test/java/com/github/pgasync/impl/TransactionTest.java
@@ -81,6 +81,17 @@ public class TransactionTest {
}
@Test
+ public void shouldCommitParameterizedInsertInTransaction() throws Exception {
+ long id = dbr.db().begin().flatMap(txn ->
+ txn.queryRows("INSERT INTO TX_TEST (ID) VALUES ($1) RETURNING ID", 35).first().flatMap(row -> {
+ Long value = row.getLong(0);
+ return txn.commit().map(v -> value);
+ })
+ ).toBlocking().single();
+ assertEquals(35L, id);
+ }
+
+ @Test
public void shouldRollbackTransaction() throws Exception {
CountDownLatch sync = new CountDownLatch(1);
Exception:
shouldCommitParameterizedInsertInTransaction(com.github.pgasync.impl.TransactionTest) Time elapsed: 0.116 sec <<< ERROR!
com.github.pgasync.SqlException: ERROR: SQLSTATE=42P02, MESSAGE=there is no parameter $1
at com.github.pgasync.impl.netty.NettyPgProtocolStream.toSqlException(NettyPgProtocolStream.java:223)
at com.github.pgasync.impl.netty.NettyPgProtocolStream.access$300(NettyPgProtocolStream.java:46)
at com.github.pgasync.impl.netty.NettyPgProtocolStream$1.onNext(NettyPgProtocolStream.java:197)
at com.github.pgasync.impl.netty.NettyPgProtocolStream$5.channelRead(NettyPgProtocolStream.java:304)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:280)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:396)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:651)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:574)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:488)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:450)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
at java.lang.Thread.run(Thread.java:745)
PR to fix sent in #35
For some strange reason, in 0.9, when I do
Transaction::queryRows
with something likeINSERT INTO TEST(FOO) VALUES($1) RETURNING ID
and I pass in the param, it fails with "ERROR: SQLSTATE=42P02, MESSAGE=there is no parameter $1". Yet, if I doquerySet
or outside of a transaction it does not. The reason for this is not obvious from looking at the code.I am working on narrowing down a test case, but it is taking a while. Any ideas in the meantime?