vertx-jdbc-client
vertx-jdbc-client copied to clipboard
getJsonArray() throws ClassCastException from v4.2.0 upwards
Version
v4.2.0
Context
We have a PostgreSQL database with a column of type Array. The following line of code always returned an JsonArray
without any problems. Once we migrated to version 4.2.x this started to throw a ClassCastException
because it returns an Object
. There were no changes to the database. Our guess is that the JDBCDecoder
from #235 somehow fails to parse the content of the cell into an array and instead just returns an Object
.
int pos = 3; // the column with the array type
// row is an JsonArray
final JsonArray jsonArray = row.getJsonArray(pos);
The documentation does'nt mention any breaking changes regarding this.
Do you have a reproducer?
No.
Steps to reproduce
- Have a database with a column of type ARRAY and a row containing valid data.
- Request the data and read from it.
Actually, java.sql.Array
will be converted to Object[]
, and keeps this value in Row
/Tuple
.
My preference is Object[]
to compatible with another lib/tool. And, in Tuple
should introduce the JsonArray converter.
https://github.com/eclipse-vertx/vertx-sql-client/blob/75ee2e4ad73d0fcf736efd80f5ea4569b72f898a/vertx-sql-client/src/main/java/io/vertx/sqlclient/Tuple.java#L414-L432
How do you think @vietj ?
we should avoid using primitive arrays with Tuple instead of trying to use a different type than what the Tuple expects (or the default methods of Tuple should be reimplemented then).