Some time ago, I reported that torque creates MySQL scripts
that look like

CREATE TABLE PERSON
(
    CODE INTEGER NOT NULL,
    LAST VARCHAR (50) NOT NULL,
    FIRST VARCHAR (50),
    BIRTH DATE,
    DEATH DATE,
    PRIMARY KEY(CODE),
    UNIQUE (LAST, FIRST),
);

Notice the comma on the last line; MySQL doesn't like it.
It seems as if there was an attempt to fix this by adding
calls to chop() and checking whether the table would have
primary keys, unique keys, etc., but this didn't work
very well for WinNT (I guess chop() has problems with
CR vs CRLF). Sooo, I patched the templates, and things look
much simpler now on the VM files. The only thing is,
the output generated looks like this:

CREATE TABLE PERSON
(
    CODE INTEGER NOT NULL 
    , LAST VARCHAR (50) NOT NULL 
    , FIRST VARCHAR (50) 
    , BIRTH DATE 
    , DEATH DATE 

    , PRIMARY KEY(CODE)


    , UNIQUE (LAST, FIRST)


);


I'm including the patch so that it can be checked. If it
is approved, I can commit it myself. Another issue would
be to apply the same method for other DBs; if this is
approved also (voting on a separate issue) I can apply
the patch to those other DBs, but won't be able to do
any testing for them

I think the mail server here (yup, you guessed, Exchange)
truncates all lines to 7x characters; hopefully this won't
matter, since I intend to apply the patch myself should it
be approved.





Index: conf/torque/templates/sql/base/mysql/columns.vm
===================================================================
RCS file:
/products/cvs/turbine/turbine/conf/torque/templates/sql/base/mysql/columns.v
m,v
retrieving revision 1.3
diff -u -r1.3 columns.vm
--- conf/torque/templates/sql/base/mysql/columns.vm     2000/12/26 03:38:04
1.3
+++ conf/torque/templates/sql/base/mysql/columns.vm     2001/01/04 14:37:04
@@ -1,9 +1,11 @@
+#set ( $comma = " " )
 #foreach ($col in $table.Columns)
     #set ( $type = $dbprops.get($col.Type) )
     #set ( $size = $col.printSize() )
     #set ( $default = $col.DefaultSetting )
     #set ( $nullString = $tstrings.select($col.isNotNull(),
$dbprops.get("NOTNULL"),"") )
     #set ( $autoIncrement = $tstrings.select($col.isAutoIncrement(),
$dbprops.get("AUTOINCREMENT"),"") )
-    #set ( $entry = "$col.Name $type $size $default $nullString
$autoIncrement," )
+    #set ( $entry = "$comma $col.Name $type $size $default $nullString
$autoIncrement" )
+    #set ( $comma = "," )
     $tstrings.sub($tstrings.collapseSpaces($entry)," ,",",")
 #end
Index: conf/torque/templates/sql/base/mysql/foreignkey.vm
===================================================================
RCS file:
/products/cvs/turbine/turbine/conf/torque/templates/sql/base/mysql/foreignke
y.vm,v
retrieving revision 1.1
diff -u -r1.1 foreignkey.vm
--- conf/torque/templates/sql/base/mysql/foreignkey.vm  2000/11/30 22:08:28
1.1
+++ conf/torque/templates/sql/base/mysql/foreignkey.vm  2001/01/04 14:37:04
@@ -1,3 +1,3 @@
 #foreach ($fk in $table.ForeignKeys)
-    FOREIGN KEY ($fk.LocalColumnNames) REFERENCES $fk.ForeignTableName
($fk.ForeignColumnNames),
+    , FOREIGN KEY ($fk.LocalColumnNames) REFERENCES $fk.ForeignTableName
($fk.ForeignColumnNames)
 #end
Index: conf/torque/templates/sql/base/mysql/index.vm
===================================================================
RCS file:
/products/cvs/turbine/turbine/conf/torque/templates/sql/base/mysql/index.vm,
v
retrieving revision 1.1
diff -u -r1.1 index.vm
--- conf/torque/templates/sql/base/mysql/index.vm       2000/11/30 22:08:29
1.1
+++ conf/torque/templates/sql/base/mysql/index.vm       2001/01/04 14:37:04
@@ -1,3 +1,3 @@
 #foreach ($index in $table.Indices)
-    INDEX $index.IndexName ($index.IndexColumnList)
+    , INDEX $index.IndexName ($index.IndexColumnList)
 #end
Index: conf/torque/templates/sql/base/mysql/primarykey.vm
===================================================================
RCS file:
/products/cvs/turbine/turbine/conf/torque/templates/sql/base/mysql/primaryke
y.vm,v
retrieving revision 1.1
diff -u -r1.1 primarykey.vm
--- conf/torque/templates/sql/base/mysql/primarykey.vm  2000/11/30 22:08:29
1.1
+++ conf/torque/templates/sql/base/mysql/primarykey.vm  2001/01/04 14:37:04
@@ -1 +1 @@
-    PRIMARY KEY($table.printPrimaryKeys()),
+    , PRIMARY KEY($table.printPrimaryKeys())
Index: conf/torque/templates/sql/base/mysql/table.vm
===================================================================
RCS file:
/products/cvs/turbine/turbine/conf/torque/templates/sql/base/mysql/table.vm,
v
retrieving revision 1.3
diff -u -r1.3 table.vm
--- conf/torque/templates/sql/base/mysql/table.vm       2000/12/14 23:35:17
1.3
+++ conf/torque/templates/sql/base/mysql/table.vm       2001/01/04 14:37:04
@@ -5,15 +5,9 @@
 $generator.parse("$basepath/drop.vm", "", "table", $tbl)
 CREATE TABLE $table.Name
 (
-#set ( $cols = $generator.parse("$basepath/columns.vm", "", "table", $tbl)
)
-#set ( $pk = $generator.parse("$basepath/primarykey.vm", "", "table", $tbl)
)
-#set ( $fk = $generator.parse("$basepath/foreignkey.vm", "", "table", $tbl)
)
-#set ( $unique = $generator.parse("$basepath/unique.vm", "", "table", $tbl)
)
-#set ( $index = $generator.parse("$basepath/index.vm", "", "table", $tbl) )
-#if($tstrings.allEmpty([$pk,$fk,$unique,$index]))$tstrings.chop($cols,1)#el
se$cols#end
-#if($tstrings.allEmpty([$fk,$unique,$index]) &&
$pk.length()>0)$tstrings.chop($pk,2)#else$pk#end
-#if($tstrings.allEmpty([$unique,$index]) && $fk.length()
>0)$tstrings.chop($fk,2)#else$fk#end
-#if($tstrings.allEmpty([$index]) &&
$unique.length()>0)$tstrings.chop($unique,2)#else$unique#end
-#if($index.length() > 0)$tstrings.chop($index,1)#end
-
+$generator.parse("$basepath/columns.vm", "", "table", $tbl)
+$generator.parse("$basepath/primarykey.vm", "", "table", $tbl)
+$generator.parse("$basepath/foreignkey.vm", "", "table", $tbl)
+$generator.parse("$basepath/unique.vm", "", "table", $tbl)
+$generator.parse("$basepath/index.vm", "", "table", $tbl)
 );
Index: conf/torque/templates/sql/base/mysql/unique.vm
===================================================================
RCS file:
/products/cvs/turbine/turbine/conf/torque/templates/sql/base/mysql/unique.vm
,v
retrieving revision 1.1
diff -u -r1.1 unique.vm
--- conf/torque/templates/sql/base/mysql/unique.vm      2000/11/30 22:08:29
1.1
+++ conf/torque/templates/sql/base/mysql/unique.vm      2001/01/04 14:37:04
@@ -1,3 +1,3 @@
 #foreach ($unique in $table.Unices)
-    UNIQUE ($unique.ColumnList),
+    , UNIQUE ($unique.ColumnList)
 #end





-- 
Gonzalo A. Diethelm
[EMAIL PROTECTED]


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to