Change the code of the template GenerateSQL to:
[#package tutorial.uml2relational] [#template public GenerateSQL(in model : relational)] [#file]generated/generatedTables.sql[/#file] [#foreach table : relational.Table in model.getInstances("Table")] -- -- TABLE ${table.name} -- DROP TABLE IF EXISTS `${table.name}`; CREATE TABLE `${table.name}` ( [#foreach column : relational.Column in table.columns] [#set sqlName = column.name.toUpperCase() sqlType = column.type.name ? "VARCHAR(255)" hasNext = column != table.columns.last()] `${sqlName}` ${sqlType} [#if hasNext],[/#if] [/#foreach] ) ENGINE=MyISAM DEFAULT CHARSET=latin1; [/#foreach] [/#template]
Directive tags (e.g. [#foreach]
) are similar to HTML tags,
but they are instructions and will not be output.
Dynamic text (e.g. ${table.name}
)
will be replaced with a calculated value in the output.
Here is the behavior of this template:
toUpperCase()
method defined on String
)
and stores the value in the variable sqlName
.sqlType
.
If the column's type is not set,
the type "VARCHAR(255)" is generated (using a default value expression).generated/generatedTables.sql
.