diff --git a/vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgParamDesc.java b/vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgParamDesc.java index 5e43152c6..1e2dc367f 100644 --- a/vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgParamDesc.java +++ b/vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgParamDesc.java @@ -69,7 +69,7 @@ public TupleBase prepare(TupleBase values) { Object[] array = (Object[]) val; Object[] tmp = new Object[array.length]; for (int j = 0;j < array.length;j++) { - tmp[j] = preparator.apply(array[j]); + tmp[j] = array[j] == null ? null : preparator.apply(array[j]); } val = tmp; } else { diff --git a/vertx-pg-client/src/test/java/io/vertx/tests/pgclient/data/NumericTypesExtendedCodecTest.java b/vertx-pg-client/src/test/java/io/vertx/tests/pgclient/data/NumericTypesExtendedCodecTest.java index 44a1c8392..0ee6508b3 100644 --- a/vertx-pg-client/src/test/java/io/vertx/tests/pgclient/data/NumericTypesExtendedCodecTest.java +++ b/vertx-pg-client/src/test/java/io/vertx/tests/pgclient/data/NumericTypesExtendedCodecTest.java @@ -535,6 +535,16 @@ public void testNumericArrayToBigDecimalArrayRowConverter(TestContext ctx) { (row, index) -> row.get(BigDecimal[].class, index)); } + @Test + public void testNumericArrayToBigDecimalArrayRowConverterWithNullElement(TestContext ctx) { + BigDecimal[] expected = {new BigDecimal("2.22"), null, new BigDecimal("3.33")}; + testGetter(ctx, + "SELECT c FROM (VALUES ($1 :: NUMERIC[])) AS t (c)", + Collections.singletonList(Tuple.tuple().addValue(expected)), + new BigDecimal[][]{expected}, + (row, index) -> row.get(BigDecimal[].class, index)); + } + @Test public void testShortArray(TestContext ctx) { testGeneric(ctx,