You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Russ Trotter <ru...@yahoo.com> on 2001/12/13 22:36:16 UTC
[PATCH] Table Type parameter for use during SQL generation
Here's a patch I made to have a "tableType" parameter that it used
during the "project-sql" task. If this parameter attribute is set
during for the TorqueSQLTask task, it sets a context parameter
"tableType" to that value. Right now, it's only referenced in the mysql
templates so that alternate table types can be specified for the
"CREATE" statements (notably the "InnoDB" type for transactions)
russ
Re: [PATCH] Table Type parameter for use during SQL generation
Posted by John McNally <jm...@collab.net>.
I modified this patch so that the property is specified in mysql's
db.props file and applied it to the Torque repo.
john mcnally
Russ Trotter wrote:
>
> Here's a patch I made to have a "tableType" parameter that it used
> during the "project-sql" task. If this parameter attribute is set
> during for the TorqueSQLTask task, it sets a context parameter
> "tableType" to that value. Right now, it's only referenced in the mysql
> templates so that alternate table types can be specified for the
> "CREATE" statements (notably the "InnoDB" type for transactions)
>
> russ
>
> ------------------------------------------------------------------------
> ? patch.out
> ? src/conf/build.xml.rtrotter
> ? src/java/org/apache/torque/task/foo.out
> Index: src/conf/build.properties
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-torque/src/conf/build.properties,v
> retrieving revision 1.7
> diff -u -r1.7 build.properties
> --- src/conf/build.properties 2001/11/01 02:23:01 1.7
> +++ src/conf/build.properties 2001/12/13 21:17:50
> @@ -47,6 +47,14 @@
>
> database = postgresql
>
> +# For MySQL you can uncomment the "tableType" line below
> +# to specify a table type for generated SQL.
> +# See mysql docs for valid table type names.
> +# For example, if you wanted to use the transactional type InnoDB,
> +# then specify "tableType = InnoDB"
> +#database = mysql
> +#tableType = MyISAM
> +
> # -------------------------------------------------------------------
> #
> # O B J E C T M O D E L I N F O R M A T I O N
> Index: src/java/org/apache/torque/task/TorqueSQLTask.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueSQLTask.java,v
> retrieving revision 1.8
> diff -u -r1.8 TorqueSQLTask.java
> --- src/java/org/apache/torque/task/TorqueSQLTask.java 2001/11/01 00:39:49 1.8
> +++ src/java/org/apache/torque/task/TorqueSQLTask.java 2001/12/13 21:17:51
> @@ -81,6 +81,10 @@
> */
> private String targetDatabase;
>
> + // The tableType attribute allows us to pass a DB-specific
> + // table type to the templates.
> + private String tableType = null;
> +
> // if the database is set than all generated sql files
> // will be placed in the specified database, the database
> // will not be taken from the data model schema file.
> @@ -129,6 +133,26 @@
> targetDatabase = v;
> }
>
> + /**
> + * Return the table table value. This value is
> + * passed to the templates and
> + * interpreted on a per-DB basis.
> + */
> + public String getTableType ()
> + {
> + return tableType;
> + }
> +
> + /**
> + * Set the table type value. This value is
> + * passed to the templates and
> + * interpreted on a per-DB basis.
> + */
> + public void setTableType (String v)
> + {
> + tableType = v;
> + }
> +
> private void createSqlDbMap()
> throws Exception
> {
> @@ -184,6 +208,10 @@
> {
> super.initControlContext();
> context.put("targetDatabase", targetDatabase);
> + if (getTableType() != null)
> + {
> + context.put("tableType", getTableType());
> + }
> createSqlDbMap();
> return context;
> }
> Index: src/templates/sql/base/mysql/table.vm
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-torque/src/templates/sql/base/mysql/table.vm,v
> retrieving revision 1.3
> diff -u -r1.3 table.vm
> --- src/templates/sql/base/mysql/table.vm 2001/11/15 00:56:26 1.3
> +++ src/templates/sql/base/mysql/table.vm 2001/12/13 21:17:51
> @@ -16,4 +16,4 @@
> #if($strings.allEmpty([$index]) && $unique.length()>0)$strings.chop($unique,2)#else$unique#end
> #if($index.length() > 0)$strings.chop($index,2)#end
>
> -);
> +)#if($tableType) Type=$tableType#end;
>
> ------------------------------------------------------------------------
> --
> 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>