Skip to content

Commit 60ef169

Browse files
committed
Fix ReleasingTransaction::queryRows to use params
1 parent 4de0779 commit 60ef169

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/main/java/com/github/pgasync/impl/PgConnectionPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public Observable<Row> queryRows(String sql, Object... params) {
269269
if (released.get()) {
270270
return Observable.error(new SqlException("Transaction is already completed"));
271271
}
272-
return transaction.queryRows(sql)
272+
return transaction.queryRows(sql, params)
273273
.doOnError(exception -> releaseConnection());
274274
}
275275

src/test/java/com/github/pgasync/impl/TransactionTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ public void shouldCommitInsertInTransaction() throws Exception {
8080
assertEquals(10L, dbr.query("SELECT ID FROM TX_TEST WHERE ID = 10").row(0).getLong(0).longValue());
8181
}
8282

83+
@Test
84+
public void shouldCommitParameterizedInsertInTransaction() throws Exception {
85+
// Ref: https://github.com/alaisi/postgres-async-driver/issues/34
86+
long id = dbr.db().begin().flatMap(txn ->
87+
txn.queryRows("INSERT INTO TX_TEST (ID) VALUES ($1) RETURNING ID", "35").first().flatMap(row -> {
88+
Long value = row.getLong(0);
89+
return txn.commit().map(v -> value);
90+
})
91+
).toBlocking().single();
92+
assertEquals(35L, id);
93+
}
94+
8395
@Test
8496
public void shouldRollbackTransaction() throws Exception {
8597
CountDownLatch sync = new CountDownLatch(1);

0 commit comments

Comments
 (0)