[CONJ-72] tinyInt1isBit is not applied by MySQLDatabaseMetaData when retrieving columns Created: 2013-10-31  Updated: 2017-01-18  Resolved: 2013-11-13

Status: Closed
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1.6

Type: Bug Priority: Major
Reporter: Bryan Turner (Inactive) Assignee: Georg Richter
Resolution: Fixed Votes: 1
Labels: None
Environment:

MariaDB Java Client 1.1.5


Issue Links:
Blocks
is blocked by CONJ-412 tinyInt1isBit is not applied in metho... Closed

 Description   

When MySQLDatabaseMetaData.getColumns(String, String, String, String) is used (by Hibernate in my particular case), it does not apply the tinyInt1isBit setting from the JDBC URL. That means it returns "tinyint" where it should be returning "bit", which causes Hibernate to fail to validate the schema.

It looks like a bug in MySQLDatabaseMetaData.dataTypeClause(String), line 99 (in the 1.1.5 source):

        " WHEN 'tinyint' THEN "     + Types.TINYINT +
        " WHEN 'year' THEN "  + (((connection.getProtocol().datatypeMappingFlags &  MySQLValueObject.YEAR_IS_DATE_TYPE)== 0)? Types.SMALLINT :Types.DATE) +

Based on the "year" line, it seems like the "tinyint" code should be:

        " WHEN 'tinyint' THEN "     + (((connection.getProtocol().datatypeMappingFlags &  MySQLValueObject.TINYINT1_IS_BIT) == 0) ? Types.TINYINT : Types.BIT) +
        " WHEN 'year' THEN "  + (((connection.getProtocol().datatypeMappingFlags &  MySQLValueObject.YEAR_IS_DATE_TYPE) == 0) ? Types.SMALLINT : Types.DATE) +



 Comments   
Comment by Bryan Turner (Inactive) [ 2013-10-31 ]

The standard MySQL Connector/J implementation correctly translates the column types in its equivalent version of this method.

Comment by Georg Richter [ 2013-11-13 ]

fixed in rev. 493

Comment by Bryan Turner (Inactive) [ 2014-04-15 ]

Unfortunately it appears this is only half a fix. The next problem is that the TYPE_NAME value is still wrong, and shows TINYINT rather than BIT. As a result, things like Hibernate validation still fail. It appears the SQL returned by columnTypeClause(String) needs something done to it as well.

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