[jira] [Created] (TORQUE-368) MySQL/MariaDb Column Default not set in generated sql for empty string
"Max Philipp Wriedt (Jira)" <[email protected]> Wed, 16 Oct 2024 10:16:00 +0000 (UTC)
| Newsgroups | gmane.comp.jakarta.turbine.torque.devel |
|---|---|
| Message-ID | <[email protected]> |
Max Philipp Wriedt created TORQUE-368:
-----------------------------------------
Summary: 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
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.
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)