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 2011/07/08 18:01:03 UTC

svn commit: r1144370 - in /db/torque/torque4/trunk/torque-test/src: main/schema/bookstore-schema.xml main/schema/pk-schema.xml main/schema/test-schema.xml test/java/org/apache/torque/DataTest.java

Author: tfischer
Date: Fri Jul  8 16:01:02 2011
New Revision: 1144370

URL: http://svn.apache.org/viewvc?rev=1144370&view=rev
Log:
- Moved tables to test different primary key types to an extra schema
- added more primary key types to multi_pk table

Added:
    db/torque/torque4/trunk/torque-test/src/main/schema/pk-schema.xml
Modified:
    db/torque/torque4/trunk/torque-test/src/main/schema/bookstore-schema.xml
    db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java

Modified: db/torque/torque4/trunk/torque-test/src/main/schema/bookstore-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/main/schema/bookstore-schema.xml?rev=1144370&r1=1144369&r2=1144370&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/main/schema/bookstore-schema.xml (original)
+++ db/torque/torque4/trunk/torque-test/src/main/schema/bookstore-schema.xml Fri Jul  8 16:01:02 2011
@@ -239,23 +239,6 @@
     </foreign-key>
   </table>
 
-
-  <!-- =================================================== -->
-  <!-- N O P K  T A B L E                                  -->
-  <!-- =================================================== -->
-
-  <table name="nopk" idMethod="none" description="this table has no pk">
-    <column
-      name="intcol"
-      type="INTEGER"
-    />
-    <column
-      name="name"
-      type="VARCHAR"
-      size="50"
-    />
-  </table>
-
   <table name="MULTIPK_SELF_REFTABLE" idMethod="none">
     <column name="COL1" primaryKey="true" required="true" type="DECIMAL"/>
     <column name="COL2" primaryKey="true" required="true" type="DECIMAL"/>

Added: db/torque/torque4/trunk/torque-test/src/main/schema/pk-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/main/schema/pk-schema.xml?rev=1144370&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/main/schema/pk-schema.xml (added)
+++ db/torque/torque4/trunk/torque-test/src/main/schema/pk-schema.xml Fri Jul  8 16:01:02 2011
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
+<!--
+ 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
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<!-- Schema which contains tables with different primary keys-->
+
+<database name="@DATABASE_DEFAULT@" 
+    defaultIdMethod="@DATABASE_ID_METHOD@"
+    package="org.apache.torque.test"
+    xmlns="http://db.apache.org/torque/4.0/templates/database"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://db.apache.org/torque/4.0/templates/database 
+        http://db.apache.org/torque/4.0/templates/database.xsd">
+
+  <table name="nopk" idMethod="none" description="this table has no pk">
+    <column name="INTCOL" type="INTEGER" />
+    <column name="NAME" type="VARCHAR" size="50" />
+  </table>
+
+  <table name="TINYINT_PK">
+    <column name="ID" primaryKey="true" type="TINYINT" />
+    <column name="NAME" type="CHAR" size="50"/>
+  </table>
+
+  <table name="SMALLINT_PK">
+    <column name="ID" primaryKey="true" type="SMALLINT" />
+    <column name="NAME" type="CHAR" size="50"/>
+  </table>
+  
+  <!--  Integer keys are defined in foreign key schema -->
+
+  <table name="VARCHAR_PK" idMethod="none">
+    <column name="ID" primaryKey="true" type="VARCHAR" size="30" />
+    <column name="NAME" type="CHAR" size="50"/>
+  </table>
+
+  <table name="VARCHAR_PK" idMethod="none">
+    <column name="ID" primaryKey="true" type="VARCHAR" size="30" />
+    <column name="NAME" type="CHAR" size="50"/>
+  </table>
+
+  <table name="TIMESTAMP_PK" idMethod="none">
+    <column name="ID" primaryKey="true" type="TIMESTAMP" />
+    <column name="NAME" type="CHAR" size="50"/>
+  </table>
+
+  <table name="FLOAT_PK" idMethod="none">
+    <column name="ID" primaryKey="true" type="FLOAT" />
+  </table>
+
+  <table name="REAL_PK" idMethod="none">
+    <column name="ID" primaryKey="true" type="REAL" />
+  </table>
+
+  <table name="DOUBLE_PK" idMethod="none">
+    <column name="ID" primaryKey="true" type="DOUBLE" />
+  </table>
+
+  <table name="LARGE_PK" idMethod="none" description="Table to test large Primary keys">
+    <column name="ID" primaryKey="true" type="BIGINT" />
+    <column name="NAME" type="VARCHAR" size="50" />
+  </table>
+
+  <table name="BIT_COMPOSITE_PK" idMethod="none">
+    <column name="PK1" primaryKey="true" type="VARCHAR" size="50"/>
+    <column name="PK2" primaryKey="true" type="BIT" javaType="object"/>
+    <column name="PAYLOAD" type="VARCHAR"  size="50"/>
+  </table>
+
+  <table name="MULTI_PK" idMethod="none">
+    <column name="pk1" required="true" primaryKey="true" type="VARCHAR" size="30" />
+    <column name="pk2" required="true" primaryKey="true" type="INTEGER" />
+    <column name="pk3" required="true" primaryKey="true" type="CHAR" size="5" />
+    <column name="pk4" required="true" primaryKey="true" type="INTEGER" javaType="object" /> 
+    <column name="pk5" required="true" primaryKey="true" type="TINYINT" javaType="object" />
+    <column name="pk6" required="true" primaryKey="true" type="SMALLINT" javaType="object" />
+    <column name="pk7" required="true" primaryKey="true" type="BIGINT" javaType="object" />
+    <column name="pk8" required="true" primaryKey="true" type="FLOAT" javaType="object" />
+    <column name="pk9" required="true" primaryKey="true" type="DOUBLE" javaType="object" />
+    <column name="pk10" required="true" primaryKey="true" type="TIMESTAMP" />
+    <column name="col_a" type="BOOLEANINT" />
+    <column name="col_b" type="BOOLEANINT" javaType="object" />
+  </table>
+
+</database>

Modified: db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml?rev=1144370&r1=1144369&r2=1144370&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml (original)
+++ db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml Fri Jul  8 16:01:02 2011
@@ -32,40 +32,6 @@
 
   <external-schema filename="ext-schema.xml" />
 
-  <!-- TRQS15 -->
-  <table name="varchar_pk" idMethod="none">
-    <column name="test_key" required="true" primaryKey="true" type="VARCHAR" size="30" />
-  </table>
-
-  <!-- TRQS17 -->
-  <table name="timestamp_pk" idMethod="none">
-    <column name="test_key" required="true" primaryKey="true" type="TIMESTAMP" />
-    <column name="col_a" type="TIMESTAMP" />
-    <!-- TRQS28 -->
-    <column name="col_b" type="BOOLEANINT" javaType="object" />
-    <column name="col_c" type="BOOLEANCHAR" javaType="object" />
-    <!-- TRQ2 -->
-    <column name="remote" type="CHAR" size="10"/>
-  </table>
-
-  <table name="BIT_COMPOSITE_PK" idMethod="none">
-    <column name="PK1" primaryKey="true" type="VARCHAR" size="50"/>
-    <column name="PK2" primaryKey="true" type="BIT" javaType="object"/>
-    <column name="PAYLOAD" type="VARCHAR"  size="50"/>
-  </table>
-
-  <!-- TRQ12 with multiple pks, combo key parse fails -->
-  <table name="multi_pk" idMethod="none">
-    <column name="pk1" required="true" primaryKey="true" type="VARCHAR" size="30" />
-    <column name="pk2" required="true" primaryKey="true" type="INTEGER" />
-    <column name="pk3" required="true" primaryKey="true" type="CHAR" size="5" />
-    <column name="pk4" required="true" primaryKey="true" type="INTEGER" javaType="object" /> 
-    <column name="pk5" required="true" primaryKey="true" type="TINYINT" javaType="object" />
-    <column name="pk6" required="true" primaryKey="true" type="TIMESTAMP" />
-    <column name="col_a" type="BOOLEANINT" />
-    <column name="col_b" type="BOOLEANINT" javaType="object" />
-  </table>
-
   <!-- TRQS77 -->
   <table name="course">
     <column name="id" required="true" primaryKey="true" type="INTEGER" javaType="object" />
@@ -116,11 +82,6 @@
     </foreign-key>
   </table>
 
-  <!-- TRQS118 primary key of type FLOAT -->
-  <table name="float_pk" idMethod="none">
-    <column name="test_key" required="true" primaryKey="true" type="FLOAT" />
-  </table>
-
   <!-- TRQS143 Generated OM will not compile if table name is Base -->
   <table name="BASE" javaName="BaseTable" idMethod="none">
     <column name="BASE_ID_CODE" primaryKey="true" required="true"
@@ -345,21 +306,6 @@
   </table>
 
 
-  <table name="LARGE_PK" idMethod="none" description="Table to test large Primary keys">
-    <column
-      name="LARGE_PK_ID"
-      required="true"
-      primaryKey="true"
-      type="BIGINT"
-    />
-    <column
-      name="NAME"
-      type="VARCHAR"
-      size="100"
-      required="false"
-    />
-  </table>
-
   <table name="SCALE_TEST" idMethod="none" description="Table to test scale attribute">
     <column
       name="SCALE_TEST_ID"
@@ -542,11 +488,11 @@ Column.getJavaObject() not implimented f
   
   <table name="SKIP_SQL" skipSql="true" description="table without SQL">
     <column name="ID" primaryKey="true" type="INTEGER" description="id for table without SQL"/>
-    <column name="FK" required="true" type="VARCHAR" size="30" />
-    <foreign-key foreignTable="varchar_pk">
+    <column name="FK" required="true" type="INTEGER" size="30" />
+    <foreign-key foreignTable="integer_pk">
       <reference 
         local="FK" 
-        foreign="test_key"/>
+        foreign="id"/>
     </foreign-key>
   </table>
 

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java?rev=1144370&r1=1144369&r2=1144370&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java Fri Jul  8 16:01:02 2011
@@ -235,7 +235,7 @@ public class DataTest extends BaseRuntim
 
         // do test
         MultiPk mpk = new MultiPk();
-        mpk.setPrimaryKey("Svarchar:N5:Schar:N3:N-42:D9999999999:");
+        mpk.setPrimaryKey("Svarchar:N5:Schar:N3:N-42:N3:N4:N5:N6:D9999999999:");
         mpk.save();
         // TODO assert saved values
     }
@@ -1686,26 +1686,26 @@ public class DataTest extends BaseRuntim
         // clean LargePk table
         Criteria criteria = new Criteria();
         criteria.add(
-                LargePkPeer.LARGE_PK_ID,
+                LargePkPeer.ID,
                 (Long) null,
                 Criteria.NOT_EQUAL);
         LargePkPeer.doDelete(criteria);
 
         long longId = 8771507845873286l;
         LargePk largePk = new LargePk();
-        largePk.setLargePkId(longId);
+        largePk.setId(longId);
         largePk.setName("testLargePk");
         largePk.save();
 
         List<LargePk> largePkList = LargePkPeer.doSelect(new Criteria());
         LargePk readLargePk = largePkList.get(0);
-        assertTrue("the inserted Id, " + largePk.getLargePkId()
-                + " , and the read id, " + readLargePk.getLargePkId()
+        assertTrue("the inserted Id, " + largePk.getId()
+                + " , and the read id, " + readLargePk.getId()
                 + " , should be equal",
-                readLargePk.getLargePkId() == largePk.getLargePkId());
-        assertTrue("the inserted Id, " + largePk.getLargePkId()
+                readLargePk.getId() == largePk.getId());
+        assertTrue("the inserted Id, " + largePk.getId()
                 + " , should be equal to " + longId,
-                longId == largePk.getLargePkId());
+                longId == largePk.getId());
     }
 
     /**



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