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 Joachim Wackerow <wa...@zuma-mannheim.de> on 2006/03/13 21:08:56 UTC

DEFAULT 'NULL' instead of DEFAULT NULL

Hi,

I just started to try DdlUtils. I encountered following problem:

A default NULL results in 'NULL' in the SQL code not in NULL without the 
quotes.

<column name="organisation" type="VARCHAR" size="50" default="NULL"/>
results in SQL code
organisation VARCHAR(50) DEFAULT 'NULL',

How can I define the NULL value in the XML file, so it does not get 
interpreted as a string value? Does exist some escape character? I 
looked thru the documentation, in some source files, and searched the 
mailing list, but didn't find anything. Did I overlook something?

Same problem with CURRENT_TIMESTAMP

<column name="timestamp" type="TIMESTAMP" default="CURRENT_TIMESTAMP"/>
results in SQL code
timestamp TIMESTAMP DEFAULT 'CURRENT_TIMESTAMP',

I like the idea of DdlUtils very much.

Achim

Re: DEFAULT 'NULL' instead of DEFAULT NULL

Posted by Joachim Wackerow <wa...@zuma-mannheim.de>.
Hi Tom,

Thank you for answer.

Thomas Dudziak wrote:
> On 3/13/06, Joachim Wackerow <wa...@zuma-mannheim.de> wrote:
> 
>> I just started to try DdlUtils. I encountered following problem:
>>
>> A default NULL results in 'NULL' in the SQL code not in NULL without the
>> quotes.
>>
>> <column name="organisation" type="VARCHAR" size="50" default="NULL"/>
>> results in SQL code
>> organisation VARCHAR(50) DEFAULT 'NULL',
>>
>> How can I define the NULL value in the XML file, so it does not get
>> interpreted as a string value? Does exist some escape character? I
>> looked thru the documentation, in some source files, and searched the
>> mailing list, but didn't find anything. Did I overlook something?
> 
> SQL NULL is the default value if you do not specify one - there is no
> other to specify it except by not specifying it.

I was not aware of this behavior.


> 
>> Same problem with CURRENT_TIMESTAMP
>>
>> <column name="timestamp" type="TIMESTAMP" default="CURRENT_TIMESTAMP"/>
>> results in SQL code
>> timestamp TIMESTAMP DEFAULT 'CURRENT_TIMESTAMP',
> 
> In general the default value is expected to be a string value that can
> be converted to the Java type corresponding to the JDBC type (as
> defined by the JDBC spec). What you need in this case would be a
> nativeDefault attribute which is not interpreted by DdlUtils at all.
> This is currently not possible, but you could add a feature request to
> DdlUtils' JIRA.

I created a feature request.

Achim

> 
> cheers,
> Tom


Re: DEFAULT 'NULL' instead of DEFAULT NULL

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/13/06, Joachim Wackerow <wa...@zuma-mannheim.de> wrote:

> I just started to try DdlUtils. I encountered following problem:
>
> A default NULL results in 'NULL' in the SQL code not in NULL without the
> quotes.
>
> <column name="organisation" type="VARCHAR" size="50" default="NULL"/>
> results in SQL code
> organisation VARCHAR(50) DEFAULT 'NULL',
>
> How can I define the NULL value in the XML file, so it does not get
> interpreted as a string value? Does exist some escape character? I
> looked thru the documentation, in some source files, and searched the
> mailing list, but didn't find anything. Did I overlook something?

SQL NULL is the default value if you do not specify one - there is no
other to specify it except by not specifying it.

> Same problem with CURRENT_TIMESTAMP
>
> <column name="timestamp" type="TIMESTAMP" default="CURRENT_TIMESTAMP"/>
> results in SQL code
> timestamp TIMESTAMP DEFAULT 'CURRENT_TIMESTAMP',

In general the default value is expected to be a string value that can
be converted to the Java type corresponding to the JDBC type (as
defined by the JDBC spec). What you need in this case would be a
nativeDefault attribute which is not interpreted by DdlUtils at all.
This is currently not possible, but you could add a feature request to
DdlUtils' JIRA.

cheers,
Tom