[CONJ-514] SelectResultSet method wasNull can't change once lastGetWasNull is set to true Created: 2017-08-28  Updated: 2017-08-30  Resolved: 2017-08-30

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 2.1.0
Fix Version/s: 2.1.1, 1.6.4

Type: Bug Priority: Major
Reporter: Daniele Maddaluno Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: SelectResultSet, resultSet


 Description   

org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet method wasNull can't change once lastGetWasNull is set to true

So this simple code taken from MyBatis always returns null values after that lastGetWasNull is set to true.
This is caused from the org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet wasNull implementation method that returns always true after the first read that sets lastGetWasNull = true, for example reading a LocalDateTime "0000-00-00 00:00:00" from the db.
That makes the read of all the following column values null.

@Override
  public T getResult(ResultSet rs, String columnName) throws SQLException {
    T result;
    try {
      result = getNullableResult(rs, columnName);
    } catch (Exception e) {
      throw new ResultMapException("Error attempting to get column '" + columnName + "' from result set.  Cause: " + e, e);
    }
    if (rs.wasNull()) {
      return null;
    } else {
      return result;
    }
  }

The documentation of the ResultSet interface method wasNull tells:
"true if the last column value read was SQL NULL and false otherwise"
so I think that that value should be reset to false in some way.



 Comments   
Comment by Diego Dupin [ 2017-08-30 ]

good description of issue !

This is corrected with commits 1 and 2.

correction is on 2.1.1 and 1.6.4.

SNAPSHOT available though maven :

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
 
<dependencies>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>2.1.1-SNAPSHOT</version>
    </dependency>
</dependencies>

Generated at Thu Feb 08 03:16:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.