db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g.@apache.org
Subject svn commit: r1870383 - in /db/torque/torque4/trunk/torque-templates/src: main/resources/org/apache/torque/templates/om/templates/recordmapper/base/ main/resources/org/apache/torque/templates/sql/conf/ main/resources/org/apache/torque/templates/sql/outl...
Date Mon, 25 Nov 2019 14:29:47 GMT
Author: gk
Date: Mon Nov 25 14:29:47 2019
New Revision: 1870383

URL: http://svn.apache.org/viewvc?rev=1870383&view=rev
Log:
- tab fix in dbObjectFieldGetter.vm
- remove alter table drop foreign key and use new globalSettings outlet for mysql to SET FOREIGN_KEY_CHECKS
= 0;
- correct logging target folder

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.groovy
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/databaseStart.groovy
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.groovy
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.vm
    db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/TestProcessing.java
    db/torque/torque4/trunk/torque-templates/src/test/resources/log4j2-test.xml
    db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-mysql.sql

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm
Mon Nov 25 14:29:47 2019
@@ -29,82 +29,81 @@
 ##
 #set ($tableElement = $torqueGen.getParent())
 #set ($dbObjectClassName = $tableElement.getAttribute("dbObjectClassName"))
-        /**
-         * Reads the value of the <code>columnIndex</code>'th column
-         * in the <code>resultSet</code> so that it can be used to set
-         * the field $field in $dbObjectClassName.
-         *
-         * @param resultSet the ResultSet to read from, not null.
-         * @param columnIndex the index in the resultSet which should be read.
-         *
-         * @return the content of the column.
-         *
-         * @throws SQLException if a problem occurs when reading
-         *         from the resultSet.
-         */
-        protected $fieldType ${getter}(
-                    ResultSet resultSet,
-                    int columnIndex)
-                throws TorqueException
+    /**
+     * Reads the value of the <code>columnIndex</code>'th column
+     * in the <code>resultSet</code> so that it can be used to set
+     * the field $field in $dbObjectClassName.
+     *
+     * @param resultSet the ResultSet to read from, not null.
+     * @param columnIndex the index in the resultSet which should be read.
+     *
+     * @return the content of the column.
+     *
+     * @throws SQLException if a problem occurs when reading
+     *         from the resultSet.
+     */
+    protected $fieldType ${getter}(
+                ResultSet resultSet,
+                int columnIndex)
+            throws TorqueException
+    {
+        try
         {
-            try
-            {
 #if ($schemaType.toString() == "BOOLEANCHAR")
-                String stringValue = resultSet.getString(columnIndex);
-                if ("Y".equals(stringValue))
-                {
-                    return true;
-                }
+            String stringValue = resultSet.getString(columnIndex);
+            if ("Y".equals(stringValue))
+            {
+                return true;
+            }
   #if ($primitive != "true")
-                else if (null == stringValue)
-                {
-                    return null;
-                }
+            else if (null == stringValue)
+            {
+                return null;
+            }
   #end
-                else
-                {
-                    return false;
-                }
+            else
+            {
+                return false;
+            }
 #elseif ($schemaType.toString() == "BOOLEANINT")
-                int intValue = resultSet.getInt(columnIndex);
-                if (1 == intValue)
-                {
-                    return true;
-                }
+            int intValue = resultSet.getInt(columnIndex);
+            if (1 == intValue)
+            {
+                return true;
+            }
   #if ($primitive != "true")
-                else if (0 == intValue && resultSet.wasNull())
-                {
-                    return null;
-                }
+            else if (0 == intValue && resultSet.wasNull())
+            {
+                return null;
+            }
   #end
-                else
-                {
-                    return false;
-                }
+            else
+            {
+                return false;
+            }
 #else
   #if ($primitive == "true" || $fieldType == "String")
     #if ($isEnum == "true")
-                return ${fieldType}.getByValue(resultSet.${resultSetGetter}(columnIndex));
+            return ${fieldType}.getByValue(resultSet.${resultSetGetter}(columnIndex));
     #else
-                return resultSet.${resultSetGetter}(columnIndex);
+            return resultSet.${resultSetGetter}(columnIndex);
     #end
   #else
     #if ($isEnum == "true")
-                ${fieldType} value = ${fieldType}.getByValue(resultSet.${resultSetGetter}(columnIndex));
+            ${fieldType} value = ${fieldType}.getByValue(resultSet.${resultSetGetter}(columnIndex));
     #else
-                ${fieldType} value = resultSet.${resultSetGetter}(columnIndex);
+            ${fieldType} value = resultSet.${resultSetGetter}(columnIndex);
     #end
-                if (resultSet.wasNull())
-                {
-                    value = null;
-                }
-                return value;
-  #end
-#end
-            }
-            catch (SQLException e)
+            if (resultSet.wasNull())
             {
-                throw new TorqueException(e);
+                value = null;
             }
+            return value;
+  #end
+#end
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
         }
-
+    }

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/conf/options.properties
Mon Nov 25 14:29:47 2019
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 torque.sql.generate.drops = true
-
+torque.sql.global.settings = true
 #The prefix for the constraint name for enum types.
 torque.sql.enumConstraintNamePrefix = 
 # The suffix for the constraint name for enum types.

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
Mon Nov 25 14:29:47 2019
@@ -28,6 +28,10 @@
       <action xsi:type="applyAction" 
           outlet="torque.sql.ddl.databaseStart"/>
     </mergepoint>
+    <mergepoint name="globalSettings">
+      <action xsi:type="applyAction" 
+          outlet="torque.sql.ddl.skipGlobalSettingsDecider"/>
+    </mergepoint>
     <mergepoint name="drop">
       <action xsi:type="applyAction" 
           outlet="torque.sql.ddl.dropSkipDecider"/>
@@ -64,6 +68,15 @@
     </mergepoint>
     <mergepoint name="databaseEnd" />
   </outlet>
+  
+  <outlet name="torque.sql.ddl.skipGlobalSettingsDecider"
+      xsi:type="groovyOutlet"
+      path="ddl/skipGlobalSettingsDecider.groovy">
+    <mergepoint name="globalSettings">
+      <action xsi:type="applyAction"
+          outlet="torque.sql.ddl.globalSettings"/>
+    </mergepoint>
+  </outlet>
 
   <outlet name="torque.sql.ddl.dropSkipDecider"
       xsi:type="groovyOutlet"
@@ -183,6 +196,10 @@
   <outlet name="torque.sql.ddl.dropTable"
       xsi:type="groovyOutlet"
       path="ddl/${option:database}/dropTable.groovy" />
+      
+  <outlet name="torque.sql.ddl.globalSettings"
+      xsi:type="groovyOutlet"
+      path="ddl/${option:database}/globalSettings.groovy"/>
 
   <outlet name="torque.sql.ddl.dropForeignKey"
       xsi:type="groovyOutlet"

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.groovy?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.groovy
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.groovy
Mon Nov 25 14:29:47 2019
@@ -18,6 +18,7 @@ import org.apache.torque.generator.templ
 
 TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
 return torqueGenGroovy.mergepoint("databaseStart") +
+  torqueGenGroovy.mergepoint("globalSettings") +
   torqueGenGroovy.mergepoint("drop") +
   torqueGenGroovy.mergepoint("createSchema") +
   torqueGenGroovy.mergepoint("tables") +

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm
Mon Nov 25 14:29:47 2019
@@ -15,6 +15,7 @@
 ## specific language governing permissions and limitations
 ## under the License.
 $torqueGen.mergepoint("databaseStart")
+$torqueGen.mergepoint("globalSettings")
 $torqueGen.mergepoint("drop")
 $torqueGen.mergepoint("createSchema")
 $torqueGen.mergepoint("tables")

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/databaseStart.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/databaseStart.groovy?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/databaseStart.groovy
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/databaseStart.groovy
Mon Nov 25 14:29:47 2019
@@ -1,3 +1,4 @@
+package org.apache.torque.templates.sql.templates.ddl.mysql;
 // Licensed to the Apache Software Foundation (ASF) under one
 // or more contributor license agreements.  See the NOTICE file
 // distributed with this work for additional information

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.groovy
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.groovy?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.groovy
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.groovy
Mon Nov 25 14:29:47 2019
@@ -20,9 +20,12 @@ import org.apache.torque.templates.model
 TorqueGenGroovy torqueGenGroovy = (TorqueGenGroovy) torqueGen
 ForeignKey foreignKey = torqueGenGroovy.model
 
-return """\
+return ""
+
+/*return """\
 ALTER TABLE $foreignKey.parent.name
     DROP FOREIGN KEY $foreignKey.name;
 
 
 """
+*/

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.vm?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/dropForeignKey.vm
Mon Nov 25 14:29:47 2019
@@ -14,7 +14,9 @@
 ## KIND, either express or implied.  See the License for the
 ## specific language governing permissions and limitations
 ## under the License.
-ALTER TABLE $torqueGen.getParent().getAttribute("name")
-    DROP FOREIGN KEY $name;
+
+## use disable foreign key if generating reproductible sql  
+##ALTER TABLE $torqueGen.getParent().getAttribute("name")
+##    DROP FOREIGN KEY $name;
 
 

Modified: db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/TestProcessing.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/TestProcessing.java?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/TestProcessing.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/test/java/org/apache/torque/templates/TestProcessing.java
Mon Nov 25 14:29:47 2019
@@ -178,6 +178,7 @@ public class TestProcessing
                 "target/generated-sql/extext-schema-create.sql");
         assertFalse(generationFolder2.exists());
     }
+    
 
     @Test
     public void testIdtableTemplates() throws Exception
@@ -333,6 +334,7 @@ public class TestProcessing
     }
 
     @ParameterizedTest //  "mysql", "oracle", "postgresql", "hsqldb", "derby",
+    //@ValueSource(strings = { "mysql" } ) 
     @ValueSource(strings = { "mysql", "oracle", "postgresql", "hsqldb", "derby", "mssql"
} )
     public void testSqlDdlTemplates(String dbType) throws Exception
     {

Modified: db/torque/torque4/trunk/torque-templates/src/test/resources/log4j2-test.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/resources/log4j2-test.xml?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/resources/log4j2-test.xml (original)
+++ db/torque/torque4/trunk/torque-templates/src/test/resources/log4j2-test.xml Mon Nov 25
14:29:47 2019
@@ -22,10 +22,10 @@
        <Console name="console" target="SYSTEM_OUT">
           <PatternLayout pattern="%d [%t] %-5p | %c - %m%n"/>
       </Console>
-      <File name="torque" fileName="./target/torque-gen/log/torque-gen.log">
+      <File name="torque" fileName="./target/torque-templates/log/torque-templates.log">
           <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
       </File>
-       <File name="velocity" fileName="./target/torque-gen/log/velocity.log">
+       <File name="velocity" fileName="./target/torque-templates/log/velocity.log">
           <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
       </File>
     </Appenders>
@@ -34,10 +34,6 @@
           <AppenderRef ref="torque" level="DEBUG"/>
           <AppenderRef ref="console" level="INFO"/>
       </Logger>
-      <Logger name="org.apache.torque.generator.template.velocity" additivity="false"
level="DEBUG">
-          <AppenderRef ref="torque" level="DEBUG"/>
-          <AppenderRef ref="console" level="INFO"/>
-      </Logger>
       <Logger name="org.apache.velocity" additivity="false" level="DEBUG">
           <AppenderRef ref="velocity" level="DEBUG"/>
           <AppenderRef ref="console" level="INFO"/>

Modified: db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-mysql.sql
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-mysql.sql?rev=1870383&r1=1870382&r2=1870383&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-mysql.sql
(original)
+++ db/torque/torque4/trunk/torque-templates/src/test/resources/org/apache/torque/templates/expected-schema-mysql.sql
Mon Nov 25 14:29:47 2019
@@ -20,45 +20,8 @@
 -- -----------------------------------------------------------------------
 
 
-ALTER TABLE r_ab
-    DROP FOREIGN KEY r_ab_FK_1;
-
-
-ALTER TABLE r_ab
-    DROP FOREIGN KEY r_ab_FK_2;
-
-
-ALTER TABLE c
-    DROP FOREIGN KEY c_FK_1;
-
-
-ALTER TABLE c
-    DROP FOREIGN KEY c_FK_2;
-
-
-ALTER TABLE c
-    DROP FOREIGN KEY c_FK_3;
-
-
-ALTER TABLE d
-    DROP FOREIGN KEY d_FK_1;
-
-
-ALTER TABLE d
-    DROP FOREIGN KEY d_FK_2;
-
-
-ALTER TABLE MULTIPK_SELF_REFTABLE
-    DROP FOREIGN KEY MULTIPK_SELF_REFTABLE_FK_1;
-
-
-ALTER TABLE ext_schema
-    DROP FOREIGN KEY ext_schema_FK_1;
-
-
-ALTER TABLE extext_schema
-    DROP FOREIGN KEY extext_schema_FK_1;
 
+SET FOREIGN_KEY_CHECKS = 0;
 
 drop table if exists a;
 drop table if exists b;



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


Mime
View raw message