diff --git a/src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java b/src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java index ab5efc9811..6642632e32 100644 --- a/src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java +++ b/src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java @@ -787,7 +787,7 @@ public int getColumnType(int col) throws SQLException { if (valueType == SQLITE_TEXT || valueType == SQLITE_NULL) { if ("CHARACTER".equals(typeName) || "NCHAR".equals(typeName) || - "NATIVE CHARACTER".equals(typeName)) { + "NATIVE CHARACTER".equals(typeName) || "CHAR".equals(typeName)) { return Types.CHAR; } diff --git a/src/test/java/org/sqlite/RSMetaDataTest.java b/src/test/java/org/sqlite/RSMetaDataTest.java index 0b066bd0ed..5cccd6397f 100644 --- a/src/test/java/org/sqlite/RSMetaDataTest.java +++ b/src/test/java/org/sqlite/RSMetaDataTest.java @@ -78,18 +78,18 @@ public void columnTypes() throws SQLException "col17 CLOB, col18 BLOB, col19 REAL, col20 DOUBLE, " + "col21 DOUBLE PRECISION, col22 FLOAT, col23 NUMERIC, " + "col24 DECIMAL(10,5), col25 BOOLEAN, col26 DATE, col27 DATETIME, " + - "col28 TIMESTAMP)" + "col28 TIMESTAMP, col29 CHAR(70))" ); // insert empty data into table otherwise getColumnType returns null stat.executeUpdate( "insert into tbl values (1, 2, 3, 4, 5, 6, 7, 8, 9," + "'c', 'varchar', 'varying', 'n', 'n','nvarchar', 'text', 'clob'," + - "null, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 0, 12345, 123456, 0)"); + "null, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 0, 12345, 123456, 0, 'char')"); meta = stat.executeQuery( "select col1, col2, col3, col4, col5, col6, col7, col8, col9, " + "col10, col11, col12, col13, col14, col15, col16, col17, col18, " + "col19, col20, col21, col22, col23, col24, col25, col26, col27, " + - "col28, " + + "col28, col29, " + "cast(col1 as boolean) from tbl" ).getMetaData(); @@ -126,8 +126,9 @@ public void columnTypes() throws SQLException assertEquals(Types.DATE, meta.getColumnType(27)); assertEquals(Types.TIMESTAMP, meta.getColumnType(28)); + assertEquals(Types.CHAR, meta.getColumnType(29)); - assertEquals(Types.BOOLEAN, meta.getColumnType(29)); + assertEquals(Types.BOOLEAN, meta.getColumnType(30)); assertEquals(10, meta.getPrecision(24)); assertEquals(5, meta.getScale(24));