You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-user@db.apache.org by Nils Tesdal <ni...@kantega.no> on 2007/03/14 14:48:02 UTC

DdlUtils insists on altering unchanged columns when using MySql

Hi!

 

I am writing program that uses DdlUtils to create and access a database.
With Derby it works ok, but when I switched to MySql I got a problem.
When I ask for the alterTablesSql, DdlUtils insists on altering columns
that are defined as 'required' without a default value. This seems to be
caused by MySql interpreting 'no default value' differently from
DdlUtils. The default value in the model read from the database contains
an empty string, while the default value in the model read from the xml
file has a null-value.

 

An example column definition:

 

<column name="DOMAIN"

    type="VARCHAR"

    size="64"

    primaryKey="true"

    required="true"/>

 

I have temporarily fixed the problem by inserting the following code in
the postprocessModelFromDatabase method on line 1957 in
PlatformImplBase.java:

 

if(column.isRequired() && defaultValue != null &&
defaultValue.equals("")) {

    defaultValue = null;

    column.setDefaultValue(defaultValue);

}

 

But maybe there is another way to go about it?

 

Nils

 

 


Re: DdlUtils insists on altering unchanged columns when using MySql

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/14/07, Nils Tesdal <ni...@kantega.no> wrote:

> I am writing program that uses DdlUtils to create and access a database.
> With Derby it works ok, but when I switched to MySql I got a problem.
> When I ask for the alterTablesSql, DdlUtils insists on altering columns
> that are defined as 'required' without a default value. This seems to be
> caused by MySql interpreting 'no default value' differently from
> DdlUtils. The default value in the model read from the database contains
> an empty string, while the default value in the model read from the xml
> file has a null-value.
>
> An example column definition:
>
> <column name="DOMAIN"
>     type="VARCHAR"
>     size="64"
>     primaryKey="true"
>     required="true"/>
>
> I have temporarily fixed the problem by inserting the following code in
> the postprocessModelFromDatabase method on line 1957 in
> PlatformImplBase.java:
>
> if(column.isRequired() && defaultValue != null &&
> defaultValue.equals("")) {
>     defaultValue = null;
>     column.setDefaultValue(defaultValue);
> }
>

What MySql version do you use ? And what version of the MySql platform ?

Tom