Wrong datatype with renameColumn

Description

In the project I am working on, we are running MSSQL Server in the actual environments, but we also the possibilities of using a local launcher during development, with MySQL as a database provider.

When defining a numeric column type, we do this:

<createTable name="SomeTable">
<column name="id" type="numeric(19,0)" [...]
</createTable>

<modifySql dbms="mysql">
<replace replace="NUMBER(19,0)" with="bigint(20)"/>
</modifySql>

This works alright (apart from the quirk of having to override the type as NUMBER when we define it as numeric).

But, when trying to rename a column, things get mucked up:

<renameColumn tableName="SomeTable" oldColumnName="OldName" newColumnName="NewName"
columnDataType="numeric(19,0)"/>

<modifySql>
<replace replace="NUMBER(19,0)" with="bigint(20)"/>
</modifySql>

This results in a the column of type DECIMAL(19, 0) in MySQL, which of course makes things fail, so we have to add another construct that resets the datatype to what it correctly should be, (like <modifyDataType>)

Curiously, adding a not-null constraint sets the datatype back to the correct one, so having

<addNotNullConstraint tableName="SomeTable" columnName="NewName" columnDataType="numeric(19,0)"/>

in the above script would result in the proper datatype (not important, but hid the error on one occation..)

Environment

Windows 7, MySQL

Activity

Show:

Nathan Voxland December 9, 2013 at 9:04 PM

This is working fine in 3.0.8. modifySql just does a "replace" and so case and spacing matters. With 3.x the numeric(19,0) is coming thorough as "NUMBER(19, 0)" so you need to use that in modifySql.

Running updateSql helps for seeing what will work for replacement

Fixed

Details

Reporter

Fix versions

Affects versions

Priority

Created November 11, 2013 at 2:56 PM
Updated December 9, 2013 at 9:04 PM
Resolved December 9, 2013 at 9:04 PM