Skip to content

Commit

Permalink
Feature/upgrade jooq (#12)
Browse files Browse the repository at this point in the history
Upgrade jooq
  • Loading branch information
larousso authored Oct 2, 2023
1 parent 70c1c1d commit 825859c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,28 @@
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.pgclient.data.Box;
import io.vertx.pgclient.data.Circle;
import io.vertx.pgclient.data.Interval;
import io.vertx.pgclient.data.Line;
import io.vertx.pgclient.data.LineSegment;
import io.vertx.pgclient.data.Path;
import io.vertx.pgclient.data.Point;
import io.vertx.pgclient.data.Polygon;
import io.vertx.pgclient.data.*;
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.Record;
import org.jooq.Table;
import org.jooq.tools.Convert;
import org.jooq.*;
import org.jooq.impl.DefaultConverterProvider;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.*;
import java.util.Arrays;
import java.util.Objects;
import java.util.UUID;


public class ReactiveRowQueryResult implements QueryResult {

private final Row current;

private final ConverterProvider converterProvider = new DefaultConverterProvider();

public ReactiveRowQueryResult(Row row) {
this.current = row;
}
Expand All @@ -55,7 +43,12 @@ public <T> T get(Field<T> field) {

@Override
public <T> T get(int index, Class<T> type) {
return Convert.convert(current.getValue(index), type);
Object value = current.getValue(index);
Converter<Object, T> provide = converterProvider.provide(Object.class, type);
if (Objects.isNull(provide)) {
throw new IllegalStateException("Provider not found");
}
return provide.from(value);
}

@Override
Expand All @@ -65,7 +58,12 @@ public <T> T get(int index, Field<T> field) {

@Override
public <T> T get(String columnName, Class<T> type) {
return Convert.convert(current.getValue(columnName), type);
Object value = current.getValue(columnName);
Converter<Object, T> provide = converterProvider.provide(Object.class, type);
if (Objects.isNull(provide)) {
throw new IllegalStateException("Provider not found");
}
return provide.from(value);
}


Expand Down

0 comments on commit 825859c

Please sign in to comment.