From c6c5a5ab6d6727e27aaaaa5e7aa7adbc07d1e309 Mon Sep 17 00:00:00 2001 From: KomachiSion <263976490@qq.com> Date: Thu, 12 Sep 2019 16:38:20 +0800 Subject: [PATCH] Fix #3027 get TINYINT and SMALLINT as INTEGER --- .../core/execute/sql/execute/result/QueryResultUtil.java | 2 -- .../execute/sql/execute/result/QueryResultUtilTest.java | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultUtil.java b/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultUtil.java index 5764737793da2..b03294ac4e8da 100644 --- a/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultUtil.java +++ b/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultUtil.java @@ -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: diff --git a/sharding-core/sharding-core-execute/src/test/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultUtilTest.java b/sharding-core/sharding-core-execute/src/test/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultUtilTest.java index b17519d57745c..7ce0b72cbbe67 100644 --- a/sharding-core/sharding-core-execute/src/test/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultUtilTest.java +++ b/sharding-core/sharding-core-execute/src/test/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultUtilTest.java @@ -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