Skip to content

Commit

Permalink
[CONJ-893] DatabaseMetaData.getColumns regression causing TINYINT(x) …
Browse files Browse the repository at this point in the history
…with x > 1 to return BIT type in place of TINYINT
  • Loading branch information
rusher committed Jul 26, 2021
1 parent f744cbb commit 673a56b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/mariadb/jdbc/MariaDbDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static String columnTypeClause(Options options) {

if (options.tinyInt1isBit) {
upperCaseWithoutSize =
" IF(COLUMN_TYPE like 'tinyint%', 'BIT', " + upperCaseWithoutSize + ")";
" IF(COLUMN_TYPE like 'tinyint(1)%', 'BIT', " + upperCaseWithoutSize + ")";
}

if (!options.yearIsDateType) {
Expand Down Expand Up @@ -547,7 +547,7 @@ private boolean catalogCond(
// table name)
private boolean patternCond(
boolean firstCondition, StringBuilder sb, String columnName, String tableName) {
if (tableName == null) {
if (tableName == null || "%".equals(tableName)) {
return firstCondition;
}
sb.append(firstCondition ? " WHERE " : " AND ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static void initClass() throws SQLException {
drop();
try (Statement stmt = sharedConnection.createStatement()) {
stmt.execute(
"CREATE TABLE yearTableMeta(xx tinyint(1), x2 tinyint(1) unsigned, yy year(4), zz bit, uu smallint)");
"CREATE TABLE yearTableMeta(xx tinyint(1), x2 tinyint(1) unsigned, x3 tinyint(4) , yy year(4), zz bit, uu smallint)");
stmt.execute("FLUSH TABLES");
}
}
Expand Down Expand Up @@ -103,6 +103,8 @@ private void checkResults(Connection connection, boolean yearAsDate, boolean tin
assertTrue(rs.next());
assertEquals(tinyAsBit ? "BIT" : "TINYINT UNSIGNED", rs.getString(6));
assertTrue(rs.next());
assertEquals("TINYINT", rs.getString(6));
assertTrue(rs.next());
assertEquals(yearAsDate ? "YEAR" : "SMALLINT", rs.getString(6));
assertEquals(yearAsDate ? null : "5", rs.getString(7)); // column size
assertEquals(yearAsDate ? null : "0", rs.getString(9)); // decimal digit
Expand Down

0 comments on commit 673a56b

Please sign in to comment.