You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Luigi <na...@iol.it> on 2003/06/17 15:21:59 UTC

modifying a template for mysql

Hi,

Since I am currently using mysql with innodb tables for my project and I 
have foreign keys with 'on update' and 'on delete' constraints. I have 
modified the templates/sql/base/mysql/foreignkey.vm file from:

-----------
#foreach ($fk in $table.ForeignKeys)
     FOREIGN KEY ($fk.LocalColumnNames) REFERENCES $fk.ForeignTableName 
($fk.ForeignColumnNames),
#end
-----------

to:

-----------
#foreach ($fk in $table.ForeignKeys)
     FOREIGN KEY ($fk.LocalColumnNames) REFERENCES $fk.ForeignTableName 
($fk.ForeignColumnNames)
#if ($fk.hasOnUpdate())
     ON UPDATE $fk.OnUpdate
#end
#if ($fk.hasOnDelete())
     ON DELETE $fk.OnDelete
#end
,
#end
-----------

This should be compatible with both innodb and myisam tables and with 
4.0.x and 3.23.5x versions of mysql (the unsupported options are simply 
ignored by the db).
In my (few, for the time being) tests it works. Can anyone please tell 
me if there is some kind of problem in his/her opinion I am overlooking 
(this is the first time I use torque, hope the question is not too stupid)?
Thanks a lot
Luigi