[ 
https://issues.apache.org/jira/browse/TORQUE-368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17891480#comment-17891480
 ] 

Georg Kallidis commented on TORQUE-368:
---------------------------------------

if it is present and the column type is of string type e.g. varchar, then it 
makes sense to not ignore an empty value. In all other cases we might through 
an exception "Please set a default value to an appropriate, non empty value for 
type x". If we would support a default "default", it would be too much hassle 
to care about all the kinds of, what is the equivalent of an empty default for 
different column types, although I am not sure, if we do indeed something like 
thos for date/time/stamp types.

Completely ignoring an "undecided" default is not the best solution, it should 
not be allowed in any case I could think of (IMO :))

 

> MySQL/MariaDb Column Default not set in generated sql for empty string
> ----------------------------------------------------------------------
>
>                 Key: TORQUE-368
>                 URL: https://issues.apache.org/jira/browse/TORQUE-368
>             Project: Torque
>          Issue Type: Bug
>          Components: Generator, Templates
>    Affects Versions: 5.1, 6.0
>            Reporter: Max Philipp Wriedt
>            Priority: Major
>
> Example XML:
> {code:java}
> <table name="feiertag" javaName="Holiday">
>     <column name="id"           primaryKey="true"       type="INTEGER"        
>                    required="true"/>
>     <column name="datum"        javaName="Date"         type="BIGINT"         
>        default="0"  required="true"/>
>     <column name="name"         javaName="Name"         type="VARCHAR"   
> size="150"  default=""   required="true"/>
>     <column name="zuschlag"     javaName="Bonus"        type="CHAR"      
> size="1"    default="N"  required="true"/>
>     <column name="bundesland"   javaName="State"        type="VARCHAR"   
> size="2"    default=""   required="true"/>
>     <unique name="dateunique"><unique-column name="datum"/></unique>
> </table> {code}
> Generates SQL:
> {code:java}
> CREATE TABLE feiertag(    
>     id INTEGER NOT NULL AUTO_INCREMENT,
>     datum BIGINT default 0 NOT NULL,
>     name VARCHAR(150) NOT NULL,
>     zuschlag CHAR(1) default 'N' NOT NULL,
>     bundesland VARCHAR(2) NOT NULL,
>     PRIMARY KEY(id),
>     UNIQUE dateunique (datum)
> ); {code}
> As you can see, the VARCHAR name and the VARCHAR bundesland are correctly 
> defined a "NOT NULL". The 
> {code:java}
> default=""{code}
> is ignored.
> This wasn't a problem until NO_ENGINE_SUBSTITUTION was set as default in 
> MySQL 5.6  & MariaDb 10.1.7 
> I wasn't able to find the corresponding generation for the DEFAULT value 
> inside the template or the generator.
> Also: should we make this switchable, i.e. if default tag is present, always 
> generate a DEFAULT or if default tag is present but empty, leave it out 
> completely?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to