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 "Adrian Price (JIRA)" <ji...@apache.org> on 2006/06/11 18:05:29 UTC

[jira] Created: (TORQUE-27) Need ability to pass global user-configurable platform-specific hints to templates

Need ability to pass global user-configurable platform-specific hints to templates
----------------------------------------------------------------------------------

         Key: TORQUE-27
         URL: http://issues.apache.org/jira/browse/TORQUE-27
     Project: Torque
        Type: Improvement

  Components: Generator  
    Versions: 3.2    
 Environment: Fedora Core 5 Linux, Sun JDK1.4.2_08.
    Reporter: Adrian Price
    Priority: Minor


It would be useful to provide a generic mechanism to enable the user to pass global platform-specific hints to templates. For example, for MySQL it is desirable to explicitly specify the type of table to be created, e.g., CREATE TABLE foo (...) Type = InnoDB. Such global hints could then be specified by the user through platform specific properties or property files, as in: 

platform.properties:
mysql.table.hint=Type = InnoDB. 

A matching table.vm template might look something like:

# -----------------------------------------------------------------------
# $table.Name
# -----------------------------------------------------------------------
$generator.parse("$basepath/drop.vm", "", "table", $tbl)
CREATE TABLE $table.Name
(
etc...
) $platform.getProperty('mysql.table.hint');

Without such a capability it is necessary to hard-code the required customizations into the templates, which is a rather inflexible and inconvenient way of doing it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Closed: (TORQUE-27) Need ability to pass global user-configurable platform-specific hints to templates

Posted by "Thomas Vandahl (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/TORQUE-27?page=all ]

Thomas Vandahl closed TORQUE-27.
--------------------------------


> Need ability to pass global user-configurable platform-specific hints to templates
> ----------------------------------------------------------------------------------
>
>                 Key: TORQUE-27
>                 URL: http://issues.apache.org/jira/browse/TORQUE-27
>             Project: Torque
>          Issue Type: Improvement
>          Components: Generator
>    Affects Versions: 3.2
>         Environment: Fedora Core 5 Linux, Sun JDK1.4.2_08.
>            Reporter: Adrian Price
>         Assigned To: Thomas Fischer
>            Priority: Minor
>             Fix For: 3.3
>
>         Attachments: XMLOptionsTagSupport.zip, XMLOptionTagSupports-Changelog.txt
>
>
> It would be useful to provide a generic mechanism to enable the user to pass global platform-specific hints to templates. For example, for MySQL it is desirable to explicitly specify the type of table to be created, e.g., CREATE TABLE foo (...) Type = InnoDB. Such global hints could then be specified by the user through platform specific properties or property files, as in: 
> platform.properties:
> mysql.table.hint=Type = InnoDB. 
> A matching table.vm template might look something like:
> # -----------------------------------------------------------------------
> # $table.Name
> # -----------------------------------------------------------------------
> $generator.parse("$basepath/drop.vm", "", "table", $tbl)
> CREATE TABLE $table.Name
> (
> etc...
> ) $platform.getProperty('mysql.table.hint');
> Without such a capability it is necessary to hard-code the required customizations into the templates, which is a rather inflexible and inconvenient way of doing it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-27) Need ability to pass global user-configurable platform-specific hints to templates

Posted by "CG Monroe (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/TORQUE-27?page=comments#action_12416023 ] 

CG Monroe commented on TORQUE-27:
---------------------------------

The main issues I can see with this are: 

It's a DB specific enhancement and IMHO Torque is designed to encourage (but not enforce) cross DB code creation.  

Should this be in Torque or done as an application specific post Torque SQL generation task?  E.g., use Torque to generate "standard" SQL then run a script to modify it as needed.  I think there are some ant edit  tasks that could be used to do this.

Also,  how many DB specific SQL script "tweaks" are out there?  If we start supporting them, how do we document the various DB specific options?

That said, there is an easy way to impliment this (or modify the templates used for your application).

All torque.* build.properties are automatically translated into template properties using the format:

torque.major.minor.sub -> $majorMinorSub

This means you could just add your own custom tags to the build properties like:

torque.mysql.table.hint=Type=InnoDB

Then modify the tempate to look like:

CREATE TABLE $table.Name
(
etc...
)  ${mysqlTableHint};

No code changes, just an application specific custom template.




> Need ability to pass global user-configurable platform-specific hints to templates
> ----------------------------------------------------------------------------------
>
>          Key: TORQUE-27
>          URL: http://issues.apache.org/jira/browse/TORQUE-27
>      Project: Torque
>         Type: Improvement

>   Components: Generator
>     Versions: 3.2
>  Environment: Fedora Core 5 Linux, Sun JDK1.4.2_08.
>     Reporter: Adrian Price
>     Priority: Minor

>
> It would be useful to provide a generic mechanism to enable the user to pass global platform-specific hints to templates. For example, for MySQL it is desirable to explicitly specify the type of table to be created, e.g., CREATE TABLE foo (...) Type = InnoDB. Such global hints could then be specified by the user through platform specific properties or property files, as in: 
> platform.properties:
> mysql.table.hint=Type = InnoDB. 
> A matching table.vm template might look something like:
> # -----------------------------------------------------------------------
> # $table.Name
> # -----------------------------------------------------------------------
> $generator.parse("$basepath/drop.vm", "", "table", $tbl)
> CREATE TABLE $table.Name
> (
> etc...
> ) $platform.getProperty('mysql.table.hint');
> Without such a capability it is necessary to hard-code the required customizations into the templates, which is a rather inflexible and inconvenient way of doing it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Resolved: (TORQUE-27) Need ability to pass global user-configurable platform-specific hints to templates

Posted by "Thomas Fischer (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/TORQUE-27?page=all ]

Thomas Fischer resolved TORQUE-27.
----------------------------------

    Fix Version/s: 3.2.1
       Resolution: Fixed
         Assignee: Thomas Fischer

Applied patch to svn.
Additionally fixed DTDReslover to work both with 3.2 and 3.2.1 DTD locally.

> Need ability to pass global user-configurable platform-specific hints to templates
> ----------------------------------------------------------------------------------
>
>                 Key: TORQUE-27
>                 URL: http://issues.apache.org/jira/browse/TORQUE-27
>             Project: Torque
>          Issue Type: Improvement
>          Components: Generator
>    Affects Versions: 3.2
>         Environment: Fedora Core 5 Linux, Sun JDK1.4.2_08.
>            Reporter: Adrian Price
>         Assigned To: Thomas Fischer
>            Priority: Minor
>             Fix For: 3.2.1
>
>         Attachments: XMLOptionsTagSupport.zip, XMLOptionTagSupports-Changelog.txt
>
>
> It would be useful to provide a generic mechanism to enable the user to pass global platform-specific hints to templates. For example, for MySQL it is desirable to explicitly specify the type of table to be created, e.g., CREATE TABLE foo (...) Type = InnoDB. Such global hints could then be specified by the user through platform specific properties or property files, as in: 
> platform.properties:
> mysql.table.hint=Type = InnoDB. 
> A matching table.vm template might look something like:
> # -----------------------------------------------------------------------
> # $table.Name
> # -----------------------------------------------------------------------
> $generator.parse("$basepath/drop.vm", "", "table", $tbl)
> CREATE TABLE $table.Name
> (
> etc...
> ) $platform.getProperty('mysql.table.hint');
> Without such a capability it is necessary to hard-code the required customizations into the templates, which is a rather inflexible and inconvenient way of doing it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Updated: (TORQUE-27) Need ability to pass global user-configurable platform-specific hints to templates

Posted by "CG Monroe (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/TORQUE-27?page=all ]

CG Monroe updated TORQUE-27:
----------------------------

    Attachment: XMLOptionsTagSupport.zip
                XMLOptionTagSupports-Changelog.txt

Support for zero or more XML <option key=".." value=".."> tags to be nested in the database, column, index, unique, and forgeign-key tags.  Intended to be a way that platform or custom information can be passed to templates.

E.g., statements like:

#if ( {table.getOption("mysql-table-type")})
  ${table.getOption("mysql-table-type")}
#end

Can be added into templates.  Then the value for "mysql-table-type" can be defined in the schema XML like:

<table ....>
   <option key="mysql-table-type" value="INNOB" />
   ....
</table>


> Need ability to pass global user-configurable platform-specific hints to templates
> ----------------------------------------------------------------------------------
>
>                 Key: TORQUE-27
>                 URL: http://issues.apache.org/jira/browse/TORQUE-27
>             Project: Torque
>          Issue Type: Improvement
>          Components: Generator
>    Affects Versions: 3.2
>         Environment: Fedora Core 5 Linux, Sun JDK1.4.2_08.
>            Reporter: Adrian Price
>            Priority: Minor
>         Attachments: XMLOptionsTagSupport.zip, XMLOptionTagSupports-Changelog.txt
>
>
> It would be useful to provide a generic mechanism to enable the user to pass global platform-specific hints to templates. For example, for MySQL it is desirable to explicitly specify the type of table to be created, e.g., CREATE TABLE foo (...) Type = InnoDB. Such global hints could then be specified by the user through platform specific properties or property files, as in: 
> platform.properties:
> mysql.table.hint=Type = InnoDB. 
> A matching table.vm template might look something like:
> # -----------------------------------------------------------------------
> # $table.Name
> # -----------------------------------------------------------------------
> $generator.parse("$basepath/drop.vm", "", "table", $tbl)
> CREATE TABLE $table.Name
> (
> etc...
> ) $platform.getProperty('mysql.table.hint');
> Without such a capability it is necessary to hard-code the required customizations into the templates, which is a rather inflexible and inconvenient way of doing it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-27) Need ability to pass global user-configurable platform-specific hints to templates

Posted by "Thoralf Rickert (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/TORQUE-27?page=comments#action_12420575 ] 

Thoralf Rickert commented on TORQUE-27:
---------------------------------------

The proposal to create application specific custom templates isn't flexible. If you upgrade torque, you've to upgrade and change your templates again. When you don't do this once a year - you've forgotten, what you did with the templates. If you use a script to change the generated code, you've to change this script too. I think one of the main goals of torque should be to have static templates that the "user" doesn't have to change.

The table type hint in this bug relates to the used storage engine in the database tables. I think mysql isn't the only database that supports more than one storage engine (this will be a key feature of future databases). So this should be an optional table specific property with a default value for the database. Of course, I'm using INNODB too and I'm using application specific templates because of that.

On the other hand it would be useful to have such hints to add database, table or column specific hints or features to the database schema (for example charset encoding, mime-types, auto-increment start values, unsigned values and so on). I think this could be in the "template properties" in the torque properties but this seems to be unusual - especially if you have to set column hints. It looks for me as a quick hack.

I think it would be better to add a new attribute to the xml tags "database", "table" and "column" (maybe other too). The value of this attribute can be added to the generated sql output (just a plain pass thru without parsing).

> Need ability to pass global user-configurable platform-specific hints to templates
> ----------------------------------------------------------------------------------
>
>          Key: TORQUE-27
>          URL: http://issues.apache.org/jira/browse/TORQUE-27
>      Project: Torque
>         Type: Improvement

>   Components: Generator
>     Versions: 3.2
>  Environment: Fedora Core 5 Linux, Sun JDK1.4.2_08.
>     Reporter: Adrian Price
>     Priority: Minor

>
> It would be useful to provide a generic mechanism to enable the user to pass global platform-specific hints to templates. For example, for MySQL it is desirable to explicitly specify the type of table to be created, e.g., CREATE TABLE foo (...) Type = InnoDB. Such global hints could then be specified by the user through platform specific properties or property files, as in: 
> platform.properties:
> mysql.table.hint=Type = InnoDB. 
> A matching table.vm template might look something like:
> # -----------------------------------------------------------------------
> # $table.Name
> # -----------------------------------------------------------------------
> $generator.parse("$basepath/drop.vm", "", "table", $tbl)
> CREATE TABLE $table.Name
> (
> etc...
> ) $platform.getProperty('mysql.table.hint');
> Without such a capability it is necessary to hard-code the required customizations into the templates, which is a rather inflexible and inconvenient way of doing it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-27) Need ability to pass global user-configurable platform-specific hints to templates

Posted by "Thomas Fischer (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/TORQUE-27?page=comments#action_12421298 ] 
            
Thomas Fischer commented on TORQUE-27:
--------------------------------------

First of all, you can tell mysql to use innoDB as default for new tables in the database's my.conf, if that is the only problem.

Then I agree with Thoralf that replacing the emplate is inflexible and error-prone, there should be a better way to do it (like being able to "override" or "extend" templates), but this is a big task and would need a major rewrite of the generator. 

Also I agree with Thoralf that if hints are added, they should be added to the schema.

A minor point is that hints will break compatibility with other databases. Up to now, if you write a db schema in Torque and do not use "bad words" (i.e. words that are reserved in one or more databases), you could create your schema on any database. I would expect hints not to be standardized in any way, so this would break compatibility.

Last, I do not know  whether hints are used in other databases than mysql. If they are not used in other databases, I do not think the schema should be cluttered up by a mysql-specific feature.



> Need ability to pass global user-configurable platform-specific hints to templates
> ----------------------------------------------------------------------------------
>
>                 Key: TORQUE-27
>                 URL: http://issues.apache.org/jira/browse/TORQUE-27
>             Project: Torque
>          Issue Type: Improvement
>          Components: Generator
>    Affects Versions: 3.2
>         Environment: Fedora Core 5 Linux, Sun JDK1.4.2_08.
>            Reporter: Adrian Price
>            Priority: Minor
>
> It would be useful to provide a generic mechanism to enable the user to pass global platform-specific hints to templates. For example, for MySQL it is desirable to explicitly specify the type of table to be created, e.g., CREATE TABLE foo (...) Type = InnoDB. Such global hints could then be specified by the user through platform specific properties or property files, as in: 
> platform.properties:
> mysql.table.hint=Type = InnoDB. 
> A matching table.vm template might look something like:
> # -----------------------------------------------------------------------
> # $table.Name
> # -----------------------------------------------------------------------
> $generator.parse("$basepath/drop.vm", "", "table", $tbl)
> CREATE TABLE $table.Name
> (
> etc...
> ) $platform.getProperty('mysql.table.hint');
> Without such a capability it is necessary to hard-code the required customizations into the templates, which is a rather inflexible and inconvenient way of doing it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-27) Need ability to pass global user-configurable platform-specific hints to templates

Posted by "CG Monroe (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/TORQUE-27?page=comments#action_12441299 ] 
            
CG Monroe commented on TORQUE-27:
---------------------------------

--- Including an e-mail thread from the torque-dev list for future reference --

Subject: Plans to add vendor-specific properties?

Greg Monroe said:

After re-reading this, a better variation occured to me.  Instead of an attribute, add an OPTION element to each main element (eg, Database, table, column, et al). This would have a key and value attribute and could be specified multiple times.

E.g.

<database....>
  <option key="mysql-db-type" value="..." />
  <option key="mssql-collate" value="..." />
  <option key="encoding" value="ISO 8859-1" />
  <table... >
    <option key=... />

This would be more generic and make it easier to read / parse.

Greg

> Thomas Fischer said:
> 
> Sounds good to me. Only I'd use the format "key1=value1,key2=value2" 
> for the sqlOptions
> 
>     Thomas
> 
> On Mon, 7 Aug 2006, Greg Monroe wrote:
> 
> > Well, here's my point of view on this.  I think this is a common 
> > enough request that we need to think about how to support stuff like 
> > this.
> > However, being a DB specifice issue, I'm not sure this should be 
> > embedded in the "core" of Torque.
> >
> > A solution I can see would be to do something similar to the 
> > following in the core code:
> >
> > 1) Modify the schema DTD to include a new attribute, sqlOptions, on 
> > all the major elements.  Define the format of this to be something 
> > that allows for a a list of key/value pairs, e.g.:
> >
> > <Table ... sqlOptions="key1, value, key1, value1">
> >
> > 2) Then add a getSqlOptions(key) method to all the matching 
> > generator classes.
> >
> > This would allow DB specific templates to be created that could have 
> > code like $table.getSqlOption(key1) in them.  Since options like 
> > this can be both DB and DB version specific, I'd see such templates 
> > being supplied as "add-ons" (using the new add-on code that I'm 
> > working on 8) ).
> >
> > So, if you need special DB features and someone has contributed an 
> > add-on set of templates, just use the Torque distro, specify and 
> > override directory, and put the add-on templates there. (And if no 
> > one has contributed one.. feel free to share.)
> >
> > This way we can semi-support DB Version X's special features, 
> > without getting the core development tied up in testing a lot of DB 
> > (and DB version) specific options support.
> >
> >> Florian Hopf said:
> >>
> >> Hi all,
> >> I'm wondering if there are any plans to include some
> vendor specific
> >> properties to Torque?
> >> Currently I'd propably need support for setting the
> character set and
> >> the storage engine in MySQL for some tables. Though I
> could modify the
> >> templates for my needs quite easily I'd appreciate a statement if 
> >> such a thing would possibly be included in Torque some time. The
> only similar
> >> reference I found is the next release section in the wiki, which 
> >> contains the suggestion to include an encoding attribute to the 
> >> database element.
> >>
> >> Kind regards
> >> Florian
> >


> Need ability to pass global user-configurable platform-specific hints to templates
> ----------------------------------------------------------------------------------
>
>                 Key: TORQUE-27
>                 URL: http://issues.apache.org/jira/browse/TORQUE-27
>             Project: Torque
>          Issue Type: Improvement
>          Components: Generator
>    Affects Versions: 3.2
>         Environment: Fedora Core 5 Linux, Sun JDK1.4.2_08.
>            Reporter: Adrian Price
>            Priority: Minor
>         Attachments: XMLOptionsTagSupport.zip, XMLOptionTagSupports-Changelog.txt
>
>
> It would be useful to provide a generic mechanism to enable the user to pass global platform-specific hints to templates. For example, for MySQL it is desirable to explicitly specify the type of table to be created, e.g., CREATE TABLE foo (...) Type = InnoDB. Such global hints could then be specified by the user through platform specific properties or property files, as in: 
> platform.properties:
> mysql.table.hint=Type = InnoDB. 
> A matching table.vm template might look something like:
> # -----------------------------------------------------------------------
> # $table.Name
> # -----------------------------------------------------------------------
> $generator.parse("$basepath/drop.vm", "", "table", $tbl)
> CREATE TABLE $table.Name
> (
> etc...
> ) $platform.getProperty('mysql.table.hint');
> Without such a capability it is necessary to hard-code the required customizations into the templates, which is a rather inflexible and inconvenient way of doing it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org