Skip to content

Commit

Permalink
Fix #3027 get TINYINT and SMALLINT as INTEGER
Browse files Browse the repository at this point in the history
  • Loading branch information
KomachiSion committed Sep 12, 2019
1 parent b7f1358 commit c6c5a5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ private static Object getValueByColumnType(final ResultSet resultSet, final int
case Types.BOOLEAN:
return resultSet.getBoolean(columnIndex);
case Types.TINYINT:
return resultSet.getByte(columnIndex);
case Types.SMALLINT:
return resultSet.getShort(columnIndex);
case Types.INTEGER:
return resultSet.getInt(columnIndex);
case Types.BIGINT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ public void assertGetValueByBoolean() throws SQLException {
@Test
public void assertGetValueByTinyint() throws SQLException {
when(resultSetMetaData.getColumnType(1)).thenReturn(Types.TINYINT);
when(resultSet.getByte(1)).thenReturn(Byte.MAX_VALUE);
assertThat((byte) QueryResultUtil.getValue(resultSet, 1), is(Byte.MAX_VALUE));
when(resultSet.getInt(1)).thenReturn(Integer.MAX_VALUE);
assertThat((int) QueryResultUtil.getValue(resultSet, 1), is(Integer.MAX_VALUE));
}

@Test
public void assertGetValueBySmallint() throws SQLException {
when(resultSetMetaData.getColumnType(1)).thenReturn(Types.SMALLINT);
when(resultSet.getShort(1)).thenReturn(Short.MAX_VALUE);
assertThat((short) QueryResultUtil.getValue(resultSet, 1), is(Short.MAX_VALUE));
when(resultSet.getInt(1)).thenReturn(Integer.MAX_VALUE);
assertThat((int) QueryResultUtil.getValue(resultSet, 1), is(Integer.MAX_VALUE));
}

@Test
Expand Down

0 comments on commit c6c5a5a

Please sign in to comment.