Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tsegismont opened this issue Sep 9, 2024 · 1 comment
Closed
Assignees
Milestone

Comments

@tsegismont
Copy link
Contributor

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;

@tsegismont tsegismont added this to the 4.5.11 milestone Sep 9, 2024
@tsegismont tsegismont self-assigned this Sep 9, 2024
tsegismont added a commit to tsegismont/vertx-sql-client that referenced this issue Sep 9, 2024
Fixes eclipse-vertx#1463

With this change, a DataType always has a param extractor.
The default extractor signals the failure to convert to PgParamDesc.

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
tsegismont added a commit to tsegismont/vertx-sql-client that referenced this issue Sep 17, 2024
Fixes eclipse-vertx#1463

With this change, a DataType always has a param extractor.
The default extractor signals the failure to convert to PgParamDesc.

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
tsegismont added a commit that referenced this issue Sep 17, 2024
#1464)

Fixes #1463

With this change, a DataType always has a param extractor.
The default extractor signals the failure to convert to PgParamDesc.

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
@tsegismont
Copy link
Contributor Author

Fixed by #1464

tsegismont added a commit to tsegismont/vertx-sql-client that referenced this issue Sep 17, 2024
eclipse-vertx#1464)

Fixes eclipse-vertx#1463

With this change, a DataType always has a param extractor.
The default extractor signals the failure to convert to PgParamDesc.

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant