liquibase treat tinyint(1) as boolean in mysql when using generateChangeLog

Description

If the type of column is tinyint(1) with a default value 2, liquibase may failed as:
liquibase.exception.DatabaseException: java.text.ParseException: Unknown bit value: 2
at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.getColumnTypeAndDefValue(JdbcDatabaseSnapshotGenerator.java:404)

Since tinyint of mysql may store any integer in the range -128..127, tinyint(1) can be used as numeric type sometime.

Environment

db:mysql

Attachments

1

Activity

Show:

Nathan Voxland May 30, 2014 at 5:39 PM

Going to have to push off looking into it more with 3.3 since there isn't a great clear answer at this point.

memoComp OpenSource October 29, 2013 at 12:50 PM

Further investigation: If I am using tinyInt1isBit=false for my jdbc connection url, "tinyInt1isBit" is a specifiic jdbc property, TINYINT(1) values from my local test database convert into TINYINT(3) by generateChangeLog command, but not into BIT(1) anymore. I thought this is a helpful thing at first, but then I run into problems if i want to migrate to hypersonic, for example, which does not support TINYINT(3) but BOOLEAN!

For short: It want to use BOOLEAN in my changesets which works in all of my cases. But for this, imho, the mentioned patch has to be applied, to convert BOOLEAN into TINYINT(1), in the case of a mysql database to avoid BIT(1). Last but not least this BIT value thing seems to be existing as of MySQL 5.0.3. Before 5.0.3, MySQL interprets BIT as TINYINT(1)? Thank you all for your ingeniousness!

memoComp OpenSource October 28, 2013 at 12:05 PM

Patch which provides a workaround and tries to help you understanding this issue. It maps liquibase booleans into MySQL's TINYINT(1) which is correct according to MySQL docs.

memoComp OpenSource October 23, 2013 at 3:07 PM

BIT(1) can be seen as BOOLEAN safely, or?

I am using int(1) now, to support default values which does not work with BIT(1) and BIT(1) is not recommended.

Really helpful would be a mapping what BOOLEAN stands for in liquibase imho (String can be an opportunity, too.)?

What do you think of a type mapping in a XML file, or else. BIT(1) can then be mapped into a liquibase type BOOLEAN and then back into TINYINT(1)/INT(1) or any other type!

Nathan Voxland October 22, 2013 at 9:45 PM

The trouble I am running into is that when you create a column of type tinyint(1) and then ask the database what type it is, it returns "bit". It looks like there is a mysql setting of tinyInt1isBit that defaults to true, I'm not sure if the jdbc driver checks this or not.

Details

Reporter

Components

Fix versions

Affects versions

Priority

Created February 18, 2013 at 8:47 AM
Updated June 10, 2015 at 7:37 PM