Skip to content

Pg Client might convert a query param to NULL if it has the wrong type #1463

@tsegismont

Description

@tsegismont

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:

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:

if (value != null && type.isAssignableFrom(value.getClass())) {
return type.cast(value);
}
return null;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions