db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Fox (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TORQUE-142) MYSQL - default timestamp set to current_timestamp generates classes incorrectly
Date Wed, 02 May 2012 12:38:51 GMT

    [ https://issues.apache.org/jira/browse/TORQUE-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13266511#comment-13266511

Thomas Fox commented on TORQUE-142:

CURRENT_DATE, CURRENT_TIME and CURRENT_TIMESTAMP all seem to be ANSI SQL defined so all of
these should be honored both by the runtime and by the generator.
> MYSQL - default timestamp set to current_timestamp generates classes incorrectly
> --------------------------------------------------------------------------------
>                 Key: TORQUE-142
>                 URL: https://issues.apache.org/jira/browse/TORQUE-142
>             Project: Torque
>          Issue Type: Bug
>          Components: Generator
>    Affects Versions: 3.3
>         Environment: Windows
>            Reporter: Sethuraman Ramasubramanian
>            Assignee: Thomas Fox
> Recently I changed all the tables in my database to include an updated_ts column.
> I have the timestamp column in mysql defined as 
> `updated_ts` TIMESTAMP NOT NULL DEFAULT now() ON UPDATE NOW(), this is the same as 
> `updated_ts` TIMESTAMP NOT NULL DEFAULT current_timestamp ON UPDATE current_timestamp
> When I generate the XML from the DB, I get the below generated. Please look at the last
> <table name="address">
>         <column name="address_id" primaryKey="true" required="true"
>             size="20" type="VARCHAR"/>
>         <column name="address_ln_1" required="true" size="150" type="VARCHAR"/>
>         <column name="address_ln_2" size="150" type="VARCHAR"/>
>         <column name="city" required="true" size="100" type="VARCHAR"/>
>         <column name="state" required="true" size="2" type="CHAR"/>
>         <column name="pincode" required="true" size="8" type="CHAR"/>
>         <column name="email_id" size="100" type="VARCHAR"/>
>         <column default="India" name="country" required="true" size="45" type="VARCHAR"/>
>         <column default="CURRENT_TIMESTAMP" name="updated_ts"
>             required="true" type="TIMESTAMP"/>
>     </table>
> Now when I generate the OM classes I get the Address object generated with the below
>  private Date updatedTs = new Date(CURRENT_TIMESTAMP);
> This results in a compilation error. 
> My questions are:
> 1. Are default timestamp values supported in Torque?
> 2. How about the "on update" clause? If a column has an on update clause, will Torque
ignore it and just send an update statement with the column to the database. This would result
in some issues, for example if I selected a row from the table and changed some values. I
then call save(), then the updated timestamp will not get updated because it already has a
value in it. Is there anyway I can change Torque in a common place to set the value to be
null, if the column name is updated_ts. This would solve this problem.
> Any help is highly appreciated.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.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

View raw message