-
Notifications
You must be signed in to change notification settings - Fork 208
Description
Originally reported in #1281
As an example, if the query has a parameter of type interval, mapped by io.vertx.pgclient.data.Interval, and the user puts a java.time.Duration, then PgClient will set the value to NULL.
It happens here:
vertx-sql-client/vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgParamDesc.java
Lines 53 to 62 in cc9803f
| Object val; | |
| try { | |
| if (extractor != null) { | |
| val = extractor.get(values, i); | |
| } else { | |
| val = values.get(paramDataType.encodingType, i); | |
| } | |
| } catch (Exception e) { | |
| return ErrorMessageFactory.buildWhenArgumentsTypeNotMatched(paramDataType.decodingType, i, values.getValue(i)); | |
| } |
We would expect the client to reject the query using a message generated by buildWhenArgumentsTypeNotMatched.
But the INTERVAL data type is defined without a type extractor:
INTERVAL(1186, true, Interval.class, JDBCType.DATE),So the client invokes values.get(paramDataType.encodingType, i);
And there the returned value is null because Interval is not assignable from Duration:
vertx-sql-client/vertx-sql-client/src/main/java/io/vertx/sqlclient/Tuple.java
Lines 1716 to 1719 in 2de7f0d
| if (value != null && type.isAssignableFrom(value.getClass())) { | |
| return type.cast(value); | |
| } | |
| return null; |