sequelize-auto
sequelize-auto copied to clipboard
MySQL fields with type BIT and default will be converted to Boolean with a default string
Consider the following MYSQL table:
CREATE TABLE `test` (
`flag` bit(1) NOT NULL DEFAULT b'0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
The field flag will be exported as the following:
'accountable': {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: '0',
}
As you can see the defaultValue is a string, but it should be a Number, like:
'accountable': {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: 0,
}
Otherwise creating the table (not specifying the field, thus using the default) will lead to error:
SequelizeDatabaseError: Data too long for column 'flag' at row 1
Fixed in [email protected]