db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriel Bauman <g...@bravenet.com>
Subject Patch for src/templates/sql/base/mysql/foreignkey.vm
Date Tue, 08 Apr 2003 22:53:59 GMT
Hi, not sure where to send this, so here you go.

I have patched the VelociMacro file that handles SQL generation for 
foreign keys under MySql. Basically, I've made it tableType sensitive. 
The patch is against cvs head.

If you do not have a tableType specified in your db.props, the template 
assumes no support for constraints and simply generates an index:

     # Foreign Key: service_id -> ftp_service.id
     INDEX ftp_account_subscription_FK_1 (service_id)

In this case, a comment containing a warning message about the missing 
features is injected as well. I feel that this warning may clear up some 
confusion among new users.

If, on the other hand, you are using InnoDB tables, an index is 
generated as above (mysql and InnoDB require this) and the proper 
FOREIGN KEY is generated as well:

     # Foreign Key: service_id -> ftp_service.id
     INDEX ftp_account_subscription_FK_1 (service_id)),
     FOREIGN KEY (service_id)
         REFERENCES ftp_service (id)
         ON DELETE CASCADE

I have taken pains to keep the output pretty at the expense of template 
readability.

I've tested as many cases as I could come up with. Comments?

Gabe


Mime
View raw message