Negative numeric values are not simple queries are not properly decoded
Querying integer column with negative value not working properly.
pg-client Row contains -29 when executing select on column with value -1.
Hi, we need a reproducer in order to investigate
Here is the unit test that reproduces the issue with version 0.10.7:
diff --git a/src/test/java/io/reactiverse/pgclient/RxTest.java b/src/test/java/io/reactiverse/pgclient/RxTest.java
index a9ce592..dcb5a5d 100644
--- a/src/test/java/io/reactiverse/pgclient/RxTest.java
+++ b/src/test/java/io/reactiverse/pgclient/RxTest.java
@@ -122,4 +122,20 @@ public class RxTest extends PgTestBase {
}, ctx::fail);
});
}
+
+ @Test
+ public void testNegativeIntegerBug(TestContext ctx) {
+ Async async = ctx.async();
+ pool.rxQuery("INSERT INTO Fortune (id, message) VALUES (-1, 'Yes')")
+ .flatMap(s -> pool.rxQuery("SELECT * FROM Fortune WHERE id=-1"))
+ .subscribe(result -> {
+ ctx.assertEquals(1, result.size());
+ Integer idFromDb = result.iterator().next().getInteger(0);
+ System.out.println("id from DB (expected -1)=" + idFromDb);
+ ctx.assertEquals(-29, idFromDb); //succeeds
+ ctx.assertEquals(-1, idFromDb); //fails here
+ async.complete();
+ }, err -> ctx.fail());
+
+ }
}
The above unit-test fails since expected id value is -1 but SELECT from DB returns -29
Running io.reactiverse.pgclient.RxTest
id from DB (expected -1)=-29
io.reactivex.exceptions.UndeliverableException: java.lang.AssertionError: Not equals : -1 != -29
at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:366)
...
Caused by: java.lang.AssertionError: Not equals : -1 != -29
at io.vertx.ext.unit.impl.TestContextImpl.reportAssertionError(TestContextImpl.java:467)
at io.vertx.ext.unit.impl.TestContextImpl.assertEquals(TestContextImpl.java:363)
at io.vertx.ext.unit.impl.TestContextImpl.assertEquals(TestContextImpl.java:350)
at io.reactiverse.pgclient.RxTest.lambda$testNegativeIntegerBug$6(RxTest.java:136)
at io.reactivex.internal.observers.ConsumerSingleObserver.onSuccess(ConsumerSingleObserver.java:63)
... 37 more
can you make a PR that adds this test ?
can you make a PR that adds this test ?
@vietj Here is the PR https://github.com/reactiverse/reactive-pg-client/pull/204
thanks
it has been fixed in the master branch, perhaps you can check with a snapshot ?