vert-x3 / vertx-jdbc-client

JDBC support for Vert.x
Apache License 2.0
126 stars 90 forks source link

Some JDBC not working properly with getObject(pos, cls) #282

Open FDoKE opened 2 years ago

FDoKE commented 2 years ago

Version

4.3.1 (last used version without an issue is 4.1.1)

Context

Looks like changes made in JDBCDecoderImpl break two of jdbc's in our project (HSQL, Clickhouse). In new version it uses cs.getObject(pos, cls) to retrieve result which act wierd with some types in HSQL, Clickhouse

Clickhouse: for example in case of double getObject(pos) returns null, getObject(pos, cls) return 0.0

Hsql: Could not pinpoint root cause, but looks like something wierd happened there: getObject(pos) returns null getObject(pos, cls) return 2 (I don't know where that coming from, fun fact that if I do getObject(pos) with debug just before vertx-jdbc retrieving it with getObject(pos,cls) as param it return correct value)

But looks like noone really made getObject(pos, cls) work properly.

My current workaraund, I replaced JDBCDecoderImpl with my own that always retrieve columns by getObject(col) But I bit worried that it will produce some unexpected behaivor later.

 @Override
    public Object parse(ResultSet rs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup) throws SQLException {
        return decode(jdbcTypeLookup.apply(pos), cls -> rs.getObject(pos));
    }

    @Override
    public Object parse(CallableStatement cs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup) throws SQLException {
        return decode(jdbcTypeLookup.apply(pos), cls -> cs.getObject(pos));
    }

I would like to hear your thoughs and why logic changed from getObject(col) to getObject(col,cls)

Do you have a reproducer?

--

Extra

Java 8