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 tf...@apache.org on 2015/08/28 05:52:57 UTC

svn commit: r1698255 - in /db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates: platform/ transformer/om/ transformer/sql/

Author: tfischer
Date: Fri Aug 28 03:52:56 2015
New Revision: 1698255

URL: http://svn.apache.org/r1698255
Log:
Reverting last commit:
The user should be notified of non working features he uses, preferably by a hard fail. So silently removing the default value is a bad idea.

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLModelTransformer.java

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java?rev=1698255&r1=1698254&r2=1698255&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java Fri Aug 28 03:52:56 2015
@@ -40,13 +40,13 @@ public interface Platform
      * @return the db specific SQL type, or null if no SQL type is defined
      *         for the given Torque type.
      */
-    SqlType getSqlTypeForSchemaType(final SchemaType schemaType);
+    SqlType getSqlTypeForSchemaType(SchemaType schemaType);
 
     /**
      * @return The RDBMS-specific SQL fragment for <code>NULL</code>
      * or <code>NOT NULL</code>.
      */
-    String getNullString(final boolean notNull);
+    String getNullString(boolean notNull);
 
     /**
      * @return The RDBMS-specific SQL fragment for autoincrement.
@@ -59,7 +59,7 @@ public interface Platform
      * @param sqlType the SQL type
      * @return true if the type has a size attribute
      */
-    boolean hasSize(final String sqlType);
+    boolean hasSize(String sqlType);
 
     /**
      * Returns if the RDBMS-specific SQL type has a scale attribute.
@@ -67,7 +67,7 @@ public interface Platform
      * @param sqlType the SQL type
      * @return true if the type has a scale attribute
      */
-    boolean hasScale(final String sqlType);
+    boolean hasScale(String sqlType);
 
     /**
      * Returns a possible SQL suffix for column definitions of certain
@@ -78,7 +78,7 @@ public interface Platform
      *
      * @return the size suffix, not null, may be empty.
      */
-    String getSizeSuffix(final String sqlType);
+    String getSizeSuffix(String sqlType);
 
     /**
      * Returns whether the "not null part" of the definition of a column
@@ -99,7 +99,7 @@ public interface Platform
      *
      * @return the escaped String, not null.
      */
-    String quoteAndEscape(final String value);
+    String quoteAndEscape(String value);
 
     /**
      * Formats the given date as date string which is parseable by the database.
@@ -108,7 +108,7 @@ public interface Platform
      *
      * @return the date string, inclusive string escaping.
      */
-    String getDateString(final Date date);
+    String getDateString(Date date);
 
     /**
      * Formats the given date as time string which is parseable by the database.
@@ -117,7 +117,7 @@ public interface Platform
      *
      * @return the time string, inclusive string escaping.
      */
-    String getTimeString(final Date date);
+    String getTimeString(Date date);
 
     /**
      * Formats the given date as timestamp string which is parseable
@@ -127,7 +127,7 @@ public interface Platform
      *
      * @return the timestamp string, inclusive string escaping.
      */
-    String getTimestampString(final Date date);
+    String getTimestampString(Date date);
 
     /**
      * Returns whether the database has schema support where a schema
@@ -137,12 +137,4 @@ public interface Platform
      * @return true if separate schema creation is possible, false if not.
      */
     boolean usesStandaloneSchema();
-
-    /**
-     * Returns whether the database supports the functions CURRENT_DATE, CURRENT_TIME and CURRENT_TIMESTAMP
-     * as default values for columns.
-     *
-     * @return true if the three methods are supported as default values, false if not.
-     */
-    boolean supportsCurrentDateFunctionsAsColumnDefaultValue();
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java?rev=1698255&r1=1698254&r2=1698255&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java Fri Aug 28 03:52:56 2015
@@ -82,8 +82,8 @@ public class PlatformDefaultImpl impleme
      * @param sqlType the sql type for the torque schema type, not null.
      */
     protected void setSchemaTypeToSqlTypeMapping(
-            final SchemaType schemaType,
-            final SqlType sqlType)
+            SchemaType schemaType,
+            SqlType sqlType)
     {
         if (schemaType == null)
         {
@@ -99,7 +99,7 @@ public class PlatformDefaultImpl impleme
     /**
      * @see Platform#getSqlTypeForSchemaType(SchemaType)
      */
-    public SqlType getSqlTypeForSchemaType(final SchemaType schemaType)
+    public SqlType getSqlTypeForSchemaType(SchemaType schemaType)
     {
         return schemaTypeToSqlTypeMap.get(schemaType);
     }
@@ -109,7 +109,7 @@ public class PlatformDefaultImpl impleme
      * disallowed.
      * @see Platform#getNullString(boolean)
      */
-    public String getNullString(final boolean notNull)
+    public String getNullString(boolean notNull)
     {
         return (notNull ? "NOT NULL" : "");
     }
@@ -126,7 +126,7 @@ public class PlatformDefaultImpl impleme
      * @see Platform#hasScale(String)
      * TODO collect info for all platforms
      */
-    public boolean hasScale(final String sqlType)
+    public boolean hasScale(String sqlType)
     {
         return true;
     }
@@ -135,7 +135,7 @@ public class PlatformDefaultImpl impleme
      * @see Platform#hasSize(String)
      * TODO collect info for all platforms
      */
-    public boolean hasSize(final String sqlType)
+    public boolean hasSize(String sqlType)
     {
         return true;
     }
@@ -150,7 +150,7 @@ public class PlatformDefaultImpl impleme
      * @return The size suffix, not null.
      *         This implementation always returns the empty string.
      */
-    public String getSizeSuffix(final String sqlType)
+    public String getSizeSuffix(String sqlType)
     {
         return StringUtils.EMPTY;
     }
@@ -166,7 +166,7 @@ public class PlatformDefaultImpl impleme
     /**
      * @see Platform#quoteAndEscape(String)
      */
-    public String quoteAndEscape(final String text)
+    public String quoteAndEscape(String text)
     {
         String result = text.replace("'", "''");
         if (escapeBackslashes())
@@ -189,7 +189,7 @@ public class PlatformDefaultImpl impleme
     /**
      * {@inheritDoc}
      */
-    public String getDateString(final Date date)
+    public String getDateString(Date date)
     {
         return getTimestampString(date);
     }
@@ -197,7 +197,7 @@ public class PlatformDefaultImpl impleme
     /**
      * {@inheritDoc}
      */
-    public String getTimeString(final Date date)
+    public String getTimeString(Date date)
     {
         return getTimestampString(date);
     }
@@ -205,7 +205,7 @@ public class PlatformDefaultImpl impleme
     /**
      * {@inheritDoc}
      */
-    public String getTimestampString(final Date date)
+    public String getTimestampString(Date date)
     {
         SimpleDateFormat dateFormat = new SimpleDateFormat(TIMESTAMP_FORMAT);
         dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
@@ -223,12 +223,4 @@ public class PlatformDefaultImpl impleme
     {
         return false;
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean supportsCurrentDateFunctionsAsColumnDefaultValue()
-    {
-        return true;
-    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java?rev=1698255&r1=1698254&r2=1698255&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java Fri Aug 28 03:52:56 2015
@@ -90,7 +90,7 @@ public class PlatformMssqlImpl extends P
      * @see Platform#getNullString(boolean)
      */
     @Override
-    public String getNullString(final boolean notNull)
+    public String getNullString(boolean notNull)
     {
         return (notNull ? "NOT NULL" : "NULL");
     }
@@ -104,8 +104,7 @@ public class PlatformMssqlImpl extends P
     /**
      * {@inheritDoc}
      */
-    @Override
-    public String getTimestampString(final Date date)
+    public String getTimestampString(Date date)
     {
         SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
         dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
@@ -119,7 +118,6 @@ public class PlatformMssqlImpl extends P
      *
      * @return this implementation returns true.
      */
-    @Override
     public boolean usesStandaloneSchema()
     {
         return true;
@@ -129,17 +127,8 @@ public class PlatformMssqlImpl extends P
      * @see Platform#hasSize(String)
      */
     @Override
-    public boolean hasSize(final String sqlType)
+    public boolean hasSize(String sqlType)
     {
         return !("IMAGE".equals(sqlType) || "TEXT".equals(sqlType));
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean supportsCurrentDateFunctionsAsColumnDefaultValue()
-    {
-        return false;
-    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java?rev=1698255&r1=1698254&r2=1698255&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java Fri Aug 28 03:52:56 2015
@@ -90,7 +90,7 @@ public class PlatformMysqlImpl extends P
      * @see Platform#hasSize(String)
      */
     @Override
-    public boolean hasSize(final String sqlType)
+    public boolean hasSize(String sqlType)
     {
         return !("MEDIUMTEXT".equals(sqlType) || "LONGTEXT".equals(sqlType)
                 || "BLOB".equals(sqlType) || "MEDIUMBLOB".equals(sqlType)
@@ -107,19 +107,10 @@ public class PlatformMysqlImpl extends P
      * {@inheritDoc}
      */
     @Override
-    public String getDateString(final Date date)
+    public String getDateString(Date date)
     {
         SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
         dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
         return dateFormat.format(date);
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean supportsCurrentDateFunctionsAsColumnDefaultValue()
-    {
-        return false;
-    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java?rev=1698255&r1=1698254&r2=1698255&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java Fri Aug 28 03:52:56 2015
@@ -70,13 +70,13 @@ public class OMColumnTransformer
     private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.S";
 
     /** Constant for the CURRENT_DATE default value for Dates. */
-    public static final String CURRENT_DATE = "CURRENT_DATE";
+    static final String CURRENT_DATE = "CURRENT_DATE";
 
     /** Constant for the CURRENT_TIME default value for Dates. */
-    public static final String CURRENT_TIME = "CURRENT_TIME";
+    static final String CURRENT_TIME = "CURRENT_TIME";
 
     /** Constant for the CURRENT_TIMESTAMP default value for Dates. */
-    public static final String CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP";
+    static final String CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP";
 
     /** Constant for the getDefaultDate method name. */
     static final String GET_DEFAULT_DATE_METHOD_NAME = "getCurrentDate";

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLModelTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLModelTransformer.java?rev=1698255&r1=1698254&r2=1698255&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLModelTransformer.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLModelTransformer.java Fri Aug 28 03:52:56 2015
@@ -25,8 +25,6 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.source.transform.SourceTransformer;
 import org.apache.torque.generator.source.transform.SourceTransformerException;
@@ -74,10 +72,7 @@ public class SQLModelTransformer impleme
     private static final IncludeSchemaTransformer includeSchemaTransformer
             = new IncludeSchemaTransformer();
 
-    /** The logger. */
-    private static Log log = LogFactory.getLog(SourceTransformer.class);
-
-    public Database transform(
+   public Database transform(
             final Object databaseModel,
             final ControllerState controllerState)
         throws SourceTransformerException
@@ -205,18 +200,6 @@ public class SQLModelTransformer impleme
 
         for (final Column column : table.columnList)
         {
-            // do not generate illegal SQL for databases which do not support CURRENT_DATE
-            if ((OMColumnTransformer.CURRENT_DATE.equalsIgnoreCase(column._default)
-                    || OMColumnTransformer.CURRENT_TIME.equalsIgnoreCase(column._default)
-                    || OMColumnTransformer.CURRENT_TIMESTAMP.equalsIgnoreCase(column._default))
-                && (SchemaType.DATE.toString().equalsIgnoreCase(column.type)
-                    || SchemaType.TIME.toString().equalsIgnoreCase(column.type)
-                    || SchemaType.TIMESTAMP.toString().equalsIgnoreCase(column.type))
-                && !getPlatform(controllerState).supportsCurrentDateFunctionsAsColumnDefaultValue())
-            {
-                column._default = null;
-                log.warn("Removed default value of " + column._default + "");
-            }
             if (column.ddlSql == null)
             {
                 column.ddlSql = getDdlSql(



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