diff --git a/build.gradle b/build.gradle index f461ac6..59486cc 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ subprojects { jacksonVersion = "2.10.5" akkaVersion = "2.6.6" vavrVersion = "0.10.0" - _jooqVersion = "3.17.4" + _jooqVersion = "3.18.6" scalaVersion = "2.13" reactorVersion = "3.4.23" } diff --git a/jooq-async-reactive/src/main/java/fr/maif/jooq/reactive/ReactiveRowQueryResult.java b/jooq-async-reactive/src/main/java/fr/maif/jooq/reactive/ReactiveRowQueryResult.java index cd27399..ceb02d2 100644 --- a/jooq-async-reactive/src/main/java/fr/maif/jooq/reactive/ReactiveRowQueryResult.java +++ b/jooq-async-reactive/src/main/java/fr/maif/jooq/reactive/ReactiveRowQueryResult.java @@ -14,12 +14,9 @@ import io.vertx.pgclient.data.Polygon; import io.vertx.sqlclient.Row; import io.vertx.sqlclient.data.Numeric; -import org.jooq.Converter; -import org.jooq.Field; -import org.jooq.JSON; -import org.jooq.JSONB; +import org.jooq.*; import org.jooq.Record; -import org.jooq.Table; +import org.jooq.impl.DefaultConverterProvider; import org.jooq.tools.Convert; import java.math.BigDecimal; @@ -31,6 +28,7 @@ import java.time.OffsetDateTime; import java.time.OffsetTime; import java.util.Arrays; +import java.util.Objects; import java.util.UUID; @@ -38,6 +36,8 @@ public class ReactiveRowQueryResult implements QueryResult { private final Row current; + private final ConverterProvider converterProvider = new DefaultConverterProvider(); + public ReactiveRowQueryResult(Row row) { this.current = row; } @@ -55,7 +55,12 @@ public T get(Field field) { @Override public T get(int index, Class type) { - return Convert.convert(current.getValue(index), type); + Object value = current.getValue(index); + Converter provide = converterProvider.provide(Object.class, type); + if (Objects.isNull(provide)) { + throw new IllegalStateException("Provider not found"); + } + return provide.from(value); } @Override @@ -65,7 +70,12 @@ public T get(int index, Field field) { @Override public T get(String columnName, Class type) { - return Convert.convert(current.getValue(columnName), type); + Object value = current.getValue(columnName); + Converter provide = converterProvider.provide(Object.class, type); + if (Objects.isNull(provide)) { + throw new IllegalStateException("Provider not found"); + } + return provide.from(value); }