You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Eric Schmidt <Er...@concur.com> on 2001/12/14 02:26:54 UTC
Turbine 2.1 / Torque / Oracle / primarykey.vm
I am working with Turbine 2.1 / Torque / Oracle and considering submittal of
a patch. I am new to all of this so I would appreciate it if someone lets me
know if I'm wasting my time; I haven't found any related discussion.
Using the org.apache.turbine.torque.TorqueSQLTask class and the release
version of torque\templates\sql\base\oracle\primarykey.vm results in a
schema.sql that does table creation that is dependent on a primary key
having been specified in the xml, despite the fact that the attribute can be
set to 'false'. The relevant vm segments:
table.vm:
CREATE TABLE $table.Name
(
...
);
#set ( $pk = $generator.parse("$basepath/primarykey.vm", "", "table",
$tbl) )
#if($pk.length()>0)$pk#end
primarykey.vm:
ALTER TABLE $table.Name
ADD CONSTRAINT ${table.Name}_PK
PRIMARY KEY ($table.printPrimaryKey());
Because table.vm checks for the length of $pk which is always > 0 given the
format of primarykey.vm, all CREATE TABLE statements in the resulting sql
will be followed by the ALTER TABLE statement *with a potentially bogus
PRIMARY KEY output.
The patch I am testing would modify primarykey.vm as follows:
#if($table.printPrimaryKey().length()>0)
ALTER TABLE $table.Name
ADD CONSTRAINT ${table.Name}_PK
PRIMARY KEY ($table.printPrimaryKey());
#end
This results in $pk in table.vm having length 0 for tables having no primary
key, and thus the ALTER TABLE statement is not produced.
Any comments or suggestions would be appreciated.
Thanks,
Eric Schmidt
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Turbine 2.1 / Torque / Oracle / primarykey.vm
Posted by John McNally <jm...@collab.net>.
I think you should be able to make the conditional based on whether any
pk's exist for the table as opposed to creating a string and checking
its length.
john mcnally
Eric Schmidt wrote:
>
> I am working with Turbine 2.1 / Torque / Oracle and considering submittal of
> a patch. I am new to all of this so I would appreciate it if someone lets me
> know if I'm wasting my time; I haven't found any related discussion.
>
> Using the org.apache.turbine.torque.TorqueSQLTask class and the release
> version of torque\templates\sql\base\oracle\primarykey.vm results in a
> schema.sql that does table creation that is dependent on a primary key
> having been specified in the xml, despite the fact that the attribute can be
> set to 'false'. The relevant vm segments:
>
> table.vm:
>
> CREATE TABLE $table.Name
> (
> ...
> );
>
> #set ( $pk = $generator.parse("$basepath/primarykey.vm", "", "table",
> $tbl) )
> #if($pk.length()>0)$pk#end
>
> primarykey.vm:
>
> ALTER TABLE $table.Name
> ADD CONSTRAINT ${table.Name}_PK
> PRIMARY KEY ($table.printPrimaryKey());
>
> Because table.vm checks for the length of $pk which is always > 0 given the
> format of primarykey.vm, all CREATE TABLE statements in the resulting sql
> will be followed by the ALTER TABLE statement *with a potentially bogus
> PRIMARY KEY output.
>
> The patch I am testing would modify primarykey.vm as follows:
>
> #if($table.printPrimaryKey().length()>0)
> ALTER TABLE $table.Name
> ADD CONSTRAINT ${table.Name}_PK
> PRIMARY KEY ($table.printPrimaryKey());
> #end
>
> This results in $pk in table.vm having length 0 for tables having no primary
> key, and thus the ALTER TABLE statement is not produced.
>
> Any comments or suggestions would be appreciated.
>
> Thanks,
>
> Eric Schmidt
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>