db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r629708 [2/2] - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/platform/ java/org/apache/ddlutils/platform/derby/ java/org/apache/ddlutils/platform/hsqldb/ java/org/apache/ddlutils/platform/mysql/ java/org/apache/ddlutils/platform/orac...
Date Thu, 21 Feb 2008 07:57:30 GMT
Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestChangeColumn.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestChangeColumn.java?rev=629708&r1=629707&r2=629708&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestChangeColumn.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestChangeColumn.java Wed Feb 20 23:57:25 2008
@@ -20,6 +20,10 @@
  */
 
 import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.Date;
 import java.util.List;
 
 import junit.framework.Test;
@@ -30,6 +34,10 @@
 /**
  * Tests changing columns, e.g. changing the data type or size.
  *
+ * TODO:
+ * - more type conversion tests (parameterized ?)
+ * - more size change tests (parameterized ?)
+ *  
  * @version $Revision: $
  */
 public class TestChangeColumn extends RoundtripTestBase
@@ -44,17 +52,26 @@
         return getTests(TestChangeColumn.class);
     }
 
+//  - change default value (add default, remove default, change default)
+//  - combined changes, e.g
+//    - type & size
+//    - type & auto increment status
+//    - type & required
+//    - size & required
+//    - required & default value
+//  - for each of the above: normal column, pk column, fk column (local), index column, unique index column
+
     /**
-     * Tests the alteration of a column datatype.
+     * Tests the alteration of a column datatype change from integer to double.
      */
-    public void testChangeDatatype1()
+    public void testColumnTypeIntegerToDouble()
     {
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='INTEGER' required='false'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
             "  </table>\n"+
             "</database>";
         final String model2Xml = 
@@ -62,7 +79,7 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='DOUBLE' required='false'/>\n"+
+            "    <column name='avalue' type='DOUBLE'/>\n"+
             "  </table>\n"+
             "</database>";
 
@@ -77,20 +94,21 @@
 
         List beans = getRows("roundtrip");
 
+        assertEquals(new Integer(1),  beans.get(0), "pk");
         assertEquals(new Double(2.0), beans.get(0), "avalue");
     }
 
     /**
-     * Tests the alteration of a column datatype.
+     * Tests the alteration of a column datatype change from smallint to varchar.
      */
-    public void testChangeDatatype2()
+    public void testColumnTypeSmallintToVarchar()
     {
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='SMALLINT' required='true'/>\n"+
+            "    <column name='avalue' type='SMALLINT'/>\n"+
             "  </table>\n"+
             "</database>";
         final String model2Xml = 
@@ -98,7 +116,7 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='VARCHAR' size='20' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='20'/>\n"+
             "  </table>\n"+
             "</database>";
 
@@ -119,78 +137,98 @@
         {
             bean.set("avalue", ((String)bean.get("avalue")).trim());
         }
-        assertEquals((Object)"2", beans.get(0), "avalue");
+        assertEquals(new Integer(1), beans.get(0), "pk");
+        assertEquals((Object)"2",    beans.get(0), "avalue");
     }
 
     /**
-     * Tests the alteration of the datatypes of PK and FK columns.
+     * Tests the alteration of a pk column datatype change from integer to double.
      */
-    public void testChangePKAndFKDatatypes()
+    public void testPKColumnTypeIntegerToDouble()
     {
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
-            "  <table name='roundtrip1'>\n"+
-            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "  </table>\n"+
-            "  <table name='roundtrip2'>\n"+
+            "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='fk' type='INTEGER' required='false'/>\n"+
-            "    <foreign-key foreignTable='roundtrip1'>\n"+
-            "      <reference local='fk' foreign='pk'/>\n"+
-            "    </foreign-key>\n"+
             "  </table>\n"+
             "</database>";
         final String model2Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
-            "  <table name='roundtrip1'>\n"+
-            "    <column name='pk' type='VARCHAR' size='128' primaryKey='true' required='true'/>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='DOUBLE' primaryKey='true' required='true'/>\n"+
             "  </table>\n"+
-            "  <table name='roundtrip2'>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Double(2.0) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Double(2.0), beans.get(0), "pk");
+    }
+
+    /**
+     * Tests the alteration of a pk column datatype change from integer to varchar.
+     */
+    public void testPKColumnTypeIntegerToVarchar()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='fk' type='VARCHAR' size='128' required='false'/>\n"+
-            "    <foreign-key foreignTable='roundtrip1'>\n"+
-            "      <reference local='fk' foreign='pk'/>\n"+
-            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='VARCHAR' size='20' primaryKey='true' required='true'/>\n"+
             "  </table>\n"+
             "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip1", new Object[] { new Integer(1) });
-        insertRow("roundtrip2", new Object[] { new Integer(1), new Integer(1) });
+        insertRow("roundtrip", new Object[] { new Integer(1) });
 
         alterDatabase(model2Xml);
 
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List     beans = getRows("roundtrip2");
+        List     beans = getRows("roundtrip");
         DynaBean bean  = (DynaBean)beans.get(0);
 
         // Some databases (e.g. DB2) pad the string for some reason, so we manually trim it
-        if (bean.get("fk") instanceof String)
+        if (bean.get("pk") instanceof String)
         {
-            bean.set("fk", ((String)bean.get("fk")).trim());
+            bean.set("pk", ((String)bean.get("pk")).trim());
         }
-        assertEquals((Object)"1", bean, "fk");
+        assertEquals((Object)"1", beans.get(0), "pk");
     }
 
     /**
-     * Tests the alteration of the sizes of PK and FK columns.
+     * Tests the change of the datatypes of PK and FK columns from integer to varchar.
      */
-    public void testChangePKAndFKSizes()
+    public void testPKAndFKColumnTypesIntegerToVarchar()
     {
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip1'>\n"+
-            "    <column name='pk' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
             "  </table>\n"+
             "  <table name='roundtrip2'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='fk' type='VARCHAR' size='32' required='false'/>\n"+
+            "    <column name='fk' type='INTEGER' required='false'/>\n"+
             "    <foreign-key foreignTable='roundtrip1'>\n"+
             "      <reference local='fk' foreign='pk'/>\n"+
             "    </foreign-key>\n"+
@@ -213,25 +251,38 @@
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip1", new Object[] { "test" });
-        insertRow("roundtrip2", new Object[] { new Integer(1), "test" });
+        insertRow("roundtrip1", new Object[] { new Integer(1) });
+        insertRow("roundtrip2", new Object[] { new Integer(1), new Integer(1) });
 
         alterDatabase(model2Xml);
 
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List     beans = getRows("roundtrip2");
-        DynaBean bean  = (DynaBean)beans.get(0);
+        List     beans1 = getRows("roundtrip1");
+        List     beans2 = getRows("roundtrip2");
+        DynaBean bean1  = (DynaBean)beans1.get(0);
+        DynaBean bean2  = (DynaBean)beans2.get(0);
 
-        assertEquals((Object)"test", bean, "fk");
+        // Some databases (e.g. DB2) pad the string for some reason, so we manually trim it
+        if (bean1.get("pk") instanceof String)
+        {
+            bean1.set("pk", ((String)bean1.get("pk")).trim());
+        }
+        if (bean2.get("fk") instanceof String)
+        {
+            bean2.set("fk", ((String)bean2.get("fk")).trim());
+        }
+        assertEquals((Object)"1",    bean1, "pk");
+        assertEquals(new Integer(1), bean2, "pk");
+        assertEquals((Object)"1",    bean2, "fk");
     }
 
     /**
      * Tests the alteration of the datatypes of columns of a PK and FK that
      * will be dropped.
      */
-    public void testChangeDroppedPKAndFKDatatypes()
+    public void testPKAndFKColumnTypesAndDropFK()
     {
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
@@ -269,21 +320,29 @@
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List     beans = getRows("roundtrip2");
-        DynaBean bean  = (DynaBean)beans.get(0);
+        List     beans1 = getRows("roundtrip1");
+        List     beans2 = getRows("roundtrip2");
+        DynaBean bean1  = (DynaBean)beans1.get(0);
+        DynaBean bean2  = (DynaBean)beans2.get(0);
 
         // Some databases (e.g. DB2) pad the string for some reason, so we manually trim it
-        if (bean.get("fk") instanceof String)
+        if (bean1.get("pk") instanceof String)
         {
-            bean.set("fk", ((String)bean.get("fk")).trim());
+            bean1.set("pk", ((String)bean1.get("pk")).trim());
         }
-        assertEquals((Object)"1", bean, "fk");
+        if (bean2.get("fk") instanceof String)
+        {
+            bean2.set("fk", ((String)bean2.get("fk")).trim());
+        }
+        assertEquals((Object)"1",    bean1, "pk");
+        assertEquals(new Integer(1), bean2, "pk");
+        assertEquals((Object)"1",    bean2, "fk");
     }
-    
+
     /**
-     * Tests the alteration of the datatypes of a column that is indexed.
+     * Tests the alteration of an indexed column datatype change from integer to double.
      */
-    public void testChangeIndexColumnDatatype()
+    public void testIndexColumnTypeIntegerToDouble()
     {
         if (!getPlatformInfo().isIndicesSupported())
         {
@@ -295,9 +354,11 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='NUMERIC' size='8' required='false'/>\n"+
-            "    <index name='avalue_index'>\n"+
-            "      <index-column name='avalue'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='20'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
             "    </index>\n"+
             "  </table>\n"+
             "</database>";
@@ -306,17 +367,18 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='INTEGER' required='false'/>\n"+
-            "    <index name='avalue_index'>\n"+
-            "      <index-column name='avalue'/>\n"+
+            "    <column name='avalue1' type='DOUBLE'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='20'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
             "    </index>\n"+
             "  </table>\n"+
             "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(1) });
-        insertRow("roundtrip", new Object[] { new Integer(2), new Integer(10) });
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2), "text" });
 
         alterDatabase(model2Xml);
 
@@ -325,24 +387,31 @@
 
         List beans = getRows("roundtrip");
 
-        assertEquals(new Integer(1), beans.get(0), "avalue");
-        assertEquals(new Integer(10), beans.get(1), "avalue");
+        assertEquals(new Integer(1),  beans.get(0), "pk");
+        assertEquals(new Double(2.0), beans.get(0), "avalue1");
+        assertEquals((Object)"text",  beans.get(0), "avalue2");
     }
 
     /**
-     * Tests the alteration of the datatypes of an indexed column where
-     * the index will be dropped.
+     * Tests the alteration of an indexed column datatype change from smallint to varchar.
      */
-    public void testChangeDroppedIndexColumnDatatype()
+    public void testIndexColumnTypeSmallintToVarchar()
     {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='NUMERIC' size='8' required='false'/>\n"+
-            "    <index name='avalue_index'>\n"+
-            "      <index-column name='avalue'/>\n"+
+            "    <column name='avalue1' type='SMALLINT'/>\n"+
+            "    <column name='avalue2' type='DOUBLE'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
             "    </index>\n"+
             "  </table>\n"+
             "</database>";
@@ -351,37 +420,57 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='INTEGER' required='false'/>\n"+
+            "    <column name='avalue1' type='VARCHAR' size='20'/>\n"+
+            "    <column name='avalue2' type='DOUBLE'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
             "  </table>\n"+
             "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(1) });
-        insertRow("roundtrip", new Object[] { new Integer(2), new Integer(10) });
+        insertRow("roundtrip", new Object[] { new Integer(1), new Short((short)2), new Double(3.0) });
 
         alterDatabase(model2Xml);
 
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans = getRows("roundtrip");
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0); 
 
-        assertEquals(new Integer(1), beans.get(0), "avalue");
-        assertEquals(new Integer(10), beans.get(1), "avalue");
+        // Some databases (e.g. DB2) pad the string for some reason, so we manually trim it
+        if (bean.get("avalue1") instanceof String)
+        {
+            bean.set("avalue1", ((String)bean.get("avalue1")).trim());
+        }
+        assertEquals(new Integer(1),  beans.get(0), "pk");
+        assertEquals((Object)"2",     beans.get(0), "avalue1");
+        assertEquals(new Double(3.0), beans.get(0), "avalue2");
     }
 
     /**
-     * Tests the alteration of a column size.
+     * Tests the alteration of the datatype of an indexed column where
+     * the index will be dropped.
      */
-    public void testChangeSize()
+    public void testIndexColumnTypeAndDropIndex()
     {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='VARCHAR' size='20' required='true'/>\n"+
+            "    <column name='avalue' type='NUMERIC' size='8' required='false'/>\n"+
+            "    <index name='avalue_index'>\n"+
+            "      <index-column name='avalue'/>\n"+
+            "    </index>\n"+
             "  </table>\n"+
             "</database>";
         final String model2Xml = 
@@ -389,13 +478,14 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='VARCHAR' size='32' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' required='false'/>\n"+
             "  </table>\n"+
             "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip", new Object[] { new Integer(1), "test" });
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(1) });
+        insertRow("roundtrip", new Object[] { new Integer(2), new Integer(10) });
 
         alterDatabase(model2Xml);
 
@@ -404,20 +494,33 @@
 
         List beans = getRows("roundtrip");
 
-        assertEquals((Object)"test", beans.get(0), "avalue");
+        assertEquals(new Integer(1),  beans.get(0), "pk");
+        assertEquals(new Integer(1),  beans.get(0), "avalue");
+        assertEquals(new Integer(2),  beans.get(1), "pk");
+        assertEquals(new Integer(10), beans.get(1), "avalue");
     }
 
     /**
-     * Tests the alteration of a column's datatype and size.
+     * Tests the alteration of an indexed column datatype change from integer to double.
      */
-    public void testChangeDatatypeAndSize()
+    public void testUniqueIndexColumnTypeIntegerToDouble()
     {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='CHAR' size='4' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='20'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
             "  </table>\n"+
             "</database>";
         final String model2Xml = 
@@ -425,13 +528,18 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='VARCHAR' size='32' required='true'/>\n"+
+            "    <column name='avalue1' type='DOUBLE'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='20'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
             "  </table>\n"+
             "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip", new Object[] { new Integer(1), "test" });
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2), "text" });
 
         alterDatabase(model2Xml);
 
@@ -440,20 +548,32 @@
 
         List beans = getRows("roundtrip");
 
-        assertEquals((Object)"test", beans.get(0), "avalue");
+        assertEquals(new Integer(1),  beans.get(0), "pk");
+        assertEquals(new Double(2.0), beans.get(0), "avalue1");
+        assertEquals((Object)"text",  beans.get(0), "avalue2");
     }
 
     /**
-     * Tests the alteration of a column null constraint.
+     * Tests the alteration of an indexed column datatype change from smallint to varchar.
      */
-    public void testChangeNull()
+    public void testUniqueIndexColumnTypeSmallintToVarchar()
     {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='INTEGER' required='true'/>\n"+
+            "    <column name='avalue1' type='SMALLINT'/>\n"+
+            "    <column name='avalue2' type='DOUBLE'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
             "  </table>\n"+
             "</database>";
         final String model2Xml = 
@@ -461,35 +581,48 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='INTEGER' required='false'/>\n"+
+            "    <column name='avalue1' type='VARCHAR' size='20'/>\n"+
+            "    <column name='avalue2' type='DOUBLE'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
             "  </table>\n"+
             "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+        insertRow("roundtrip", new Object[] { new Integer(1), new Short((short)2), new Double(3.0) });
 
-    	alterDatabase(model2Xml);
+        alterDatabase(model2Xml);
 
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans = getRows("roundtrip");
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0); 
 
-        assertEquals(new Integer(2), beans.get(0), "avalue");
+        // Some databases (e.g. DB2) pad the string for some reason, so we manually trim it
+        if (bean.get("avalue1") instanceof String)
+        {
+            bean.set("avalue1", ((String)bean.get("avalue1")).trim());
+        }
+        assertEquals(new Integer(1),  beans.get(0), "pk");
+        assertEquals((Object)"2",     beans.get(0), "avalue1");
+        assertEquals(new Double(3.0), beans.get(0), "avalue2");
     }
 
     /**
-     * Tests the addition of a column's default value.
+     * Tests increasng the size of a column.
      */
-    public void testAddDefault()
+    public void testColumnIncreaseSize()
     {
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='DOUBLE'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='20' required='true'/>\n"+
             "  </table>\n"+
             "</database>";
         final String model2Xml = 
@@ -497,35 +630,36 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='DOUBLE' default='2.0'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='32' required='true'/>\n"+
             "  </table>\n"+
             "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip", new Object[] { new Integer(1), new Double(2.0) });
+        insertRow("roundtrip", new Object[] { new Integer(1), "test" });
 
-    	alterDatabase(model2Xml);
+        alterDatabase(model2Xml);
 
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
         List beans = getRows("roundtrip");
 
-        assertEquals(new Double(2.0), beans.get(0), "avalue");
+        assertEquals(new Integer(1), beans.get(0), "pk");
+        assertEquals((Object)"test", beans.get(0), "avalue");
     }
 
     /**
-     * Tests the change of a column default value.
+     * Tests decreasing the size of a column.
      */
-    public void testChangeDefault()
+    public void testColumnDecreaseSize()
     {
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='INTEGER' default='1'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='32' required='true'/>\n"+
             "  </table>\n"+
             "</database>";
         final String model2Xml = 
@@ -533,203 +667,3656 @@
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='INTEGER' default='20'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='16' required='true'/>\n"+
             "  </table>\n"+
             "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+        insertRow("roundtrip", new Object[] { new Integer(1), "12345678901234567890123456789012" });
 
-    	alterDatabase(model2Xml);
+        alterDatabase(model2Xml);
 
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans = getRows("roundtrip");
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0);
 
-        assertEquals(new Integer(2), beans.get(0), "avalue");
+        assertEquals(new Integer(1), bean, "pk");
+        assertTrue("12345678901234567890123456789012".equals(bean.get("avalue")) || "1234567890123456".equals(bean.get("avalue")));
     }
 
     /**
-     * Tests the removal of a column default value.
+     * Tests increasing the size of a primary key column.
      */
-    public void testDropDefault()
+    public void testPKColumnIncreaseSize()
     {
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
-            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='VARCHAR' size='20' default='test'/>\n"+
+            "    <column name='pk' type='CHAR' size='20' primaryKey='true' required='true'/>\n"+
             "  </table>\n"+
             "</database>";
         final String model2Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
-            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='avalue' type='VARCHAR' size='20'/>\n"+
+            "    <column name='pk' type='CHAR' size='32' primaryKey='true' required='true'/>\n"+
             "  </table>\n"+
             "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip", new Object[] { new Integer(1) });
+        insertRow("roundtrip", new Object[] { "test" });
 
-    	alterDatabase(model2Xml);
+        alterDatabase(model2Xml);
 
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans = getRows("roundtrip");
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0);
 
-        assertEquals((Object)"test", beans.get(0), "avalue");
+        assertEquals("test", ((String)bean.get("pk")).trim());
     }
 
     /**
-     * Tests the change of a column's auto-increment state.
+     * Tests decreasing the size of a column.
      */
-    public void testMakeAutoIncrement()
+    public void testPKColumnDecreaseSize()
     {
-        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
-        {
-            return;
-        }
-        // Sybase does not like INTEGER auto-increment columns
-        if (SybasePlatform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            String  model1Xml = 
-                "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-                "<database name='roundtriptest'>\n"+
-                "  <table name='roundtrip'>\n"+
-                "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-                "    <column name='avalue' type='NUMERIC' size='12,0'/>\n"+
-                "  </table>\n"+
-                "</database>";
-            String model2Xml =
-                "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-                "<database name='roundtriptest'>\n"+
-                "  <table name='roundtrip'>\n"+
-                "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-                "    <column name='avalue' type='NUMERIC' size='12,0' autoIncrement='true' required='true'/>\n"+
-                "  </table>\n"+
-                "</database>";
-
-            createDatabase(model1Xml);
-
-            insertRow("roundtrip", new Object[] { new Integer(1), new BigDecimal(2) });
-
-            alterDatabase(model2Xml);
-
-            assertEquals(getAdjustedModel(),
-                         readModelFromDatabase("roundtriptest"));
-
-            List beans = getRows("roundtrip");
-
-            assertEquals(new BigDecimal(2), beans.get(0), "avalue");
-        }
-        else
-        {
-            String  model1Xml = 
-                "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-                "<database name='roundtriptest'>\n"+
-                "  <table name='roundtrip'>\n"+
-                "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-                "    <column name='avalue' type='INTEGER'/>\n"+
-                "  </table>\n"+
-                "</database>";
-            String model2Xml=
-                "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-                "<database name='roundtriptest'>\n"+
-                "  <table name='roundtrip'>\n"+
-                "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-                "    <column name='avalue' type='INTEGER' autoIncrement='true' required='true'/>\n"+
-                "  </table>\n"+
-                "</database>";
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='CHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='CHAR' size='16' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
 
-            createDatabase(model1Xml);
+        createDatabase(model1Xml);
 
-            insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
+        insertRow("roundtrip", new Object[] { "12345678901234567890123456789012" });
 
-            alterDatabase(model2Xml);
+        alterDatabase(model2Xml);
 
-            assertEquals(getAdjustedModel(),
-                         readModelFromDatabase("roundtriptest"));
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
 
-            List beans = getRows("roundtrip");
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0);
 
-            assertEquals(new Integer(2), beans.get(0), "avalue");
-        }
+        assertTrue("12345678901234567890123456789012".equals(bean.get("pk")) || "1234567890123456".equals(bean.get("pk")));
     }
 
     /**
-     * Tests the removal the column auto-increment status.
+     * Tests increasing the sizes of PK and FK columns.
      */
-    public void testDropAutoIncrement()
+    public void testPKAndFKColumnIncreaseSize()
     {
-        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
-        {
-            return;
-        }
-
-        boolean      isSybase = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
-        final String model1Xml; 
-        final String model2Xml;
-
-        if (isSybase)
-        {
-            model1Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-                        "<database name='roundtriptest'>\n"+
-                        "  <table name='roundtrip'>\n"+
-                        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-                        "    <column name='avalue' type='NUMERIC' size='12,0' required='true' autoIncrement='true'/>\n"+
-                        "  </table>\n"+
-                        "</database>";
-            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-                        "<database name='roundtriptest'>\n"+
-                        "  <table name='roundtrip'>\n"+
-                        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-                        "    <column name='avalue' type='NUMERIC' size='12,0' required='true' autoIncrement='false'/>\n"+
-                        "  </table>\n"+
-                        "</database>";
-        }
-        else
-        {
-            model1Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-                        "<database name='roundtriptest'>\n"+
-                        "  <table name='roundtrip'>\n"+
-                        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-                        "    <column name='avalue' type='INTEGER' autoIncrement='true'/>\n"+
-                        "  </table>\n"+
-                        "</database>";
-            model2Xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-                        "<database name='roundtriptest'>\n"+
-                        "  <table name='roundtrip'>\n"+
-                        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-                        "    <column name='avalue' type='INTEGER' autoIncrement='false'/>\n"+
-                        "  </table>\n"+
-                        "</database>";
-        }
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='VARCHAR' size='32' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='VARCHAR' size='128' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='VARCHAR' size='128' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
 
         createDatabase(model1Xml);
 
-        insertRow("roundtrip", new Object[] { new Integer(1) });
+        insertRow("roundtrip1", new Object[] { "test" });
+        insertRow("roundtrip2", new Object[] { new Integer(1), "test" });
 
-    	alterDatabase(model2Xml);
+        alterDatabase(model2Xml);
 
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans = getRows("roundtrip");
+        List beans1 = getRows("roundtrip1");
+        List beans2 = getRows("roundtrip2");
 
-        if (isSybase)
-        {
-            assertEquals(new BigDecimal(1), beans.get(0), "avalue");
-        }
-        else
-        {
-            assertEquals(new Integer(1), beans.get(0), "avalue");
-        }
+        assertEquals((Object)"test", beans1.get(0), "pk");
+        assertEquals(new Integer(1), beans2.get(0), "pk");
+        assertEquals((Object)"test", beans2.get(0), "fk");
+    }
+
+    /**
+     * Tests decreasing the sizes of PK and FK columns.
+     */
+    public void testPKAndFKColumnDecreaseSize()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='CHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='CHAR' size='32' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='CHAR' size='16' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='CHAR' size='16' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip1", new Object[] { "test" });
+        insertRow("roundtrip2", new Object[] { new Integer(1), "test" });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List     beans1 = getRows("roundtrip1");
+        List     beans2 = getRows("roundtrip2");
+        DynaBean bean1  = (DynaBean)beans1.get(0);
+        DynaBean bean2  = (DynaBean)beans2.get(0);
+
+        assertEquals("test", ((String)bean1.get("pk")).trim());
+        assertEquals(new Integer(1),             bean2, "pk");
+        assertEquals("test", ((String)bean2.get("fk")).trim());
+    }
+
+    /**
+     * Tests increasing the size of an indexed column.
+     */
+    public void testIndexColumnIncreaseSize()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='20'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='40'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2), "text" });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
+        assertEquals(new Integer(2), beans.get(0), "avalue1");
+        assertEquals((Object)"text", beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests decreasing the size of an indexed column.
+     */
+    public void testIndexColumnDecreaseSize()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='CHAR' size='32'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='CHAR' size='20'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2), "text" });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0);
+
+        assertEquals(new Integer(1), bean, "pk");
+        assertEquals(new Integer(2), bean, "avalue1");
+        assertEquals((Object)"text", ((String)bean.get("avalue2")).trim());
+    }
+
+    /**
+     * Tests increasing the size of an indexed column.
+     */
+    public void testUniqueIndexColumnIncreaseSize()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='CHAR' size='16'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='CHAR' size='20'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2), "text" });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0);
+
+        assertEquals(new Integer(1), bean, "pk");
+        assertEquals(new Integer(2), bean, "avalue1");
+        assertEquals((Object)"text", ((String)bean.get("avalue2")).trim());
+    }
+
+    /**
+     * Tests decreasing the size of an indexed column.
+     */
+    public void testUniqueIndexColumnDecreaseSize()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='40'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='20'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2), "text" });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
+        assertEquals(new Integer(2), beans.get(0), "avalue1");
+        assertEquals((Object)"text", beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests increasing the precision of a column.
+     */
+    public void testColumnIncreasePrecision()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='NUMERIC' size='10,5' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='NUMERIC' size='16,5' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new BigDecimal("12345.12345") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
+        assertEquals(new BigDecimal("12345.12345"), beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests decreasng the precision of a column.
+     */
+    public void testColumnDecreasePrecision()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DECIMAL' size='12,5' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DECIMAL' size='10,5' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new BigDecimal("12345.12345") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
+        assertEquals(new BigDecimal("12345.12345"), beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests increasing the precision of a primary key column.
+     */
+    public void testPKColumnIncreasePrecision()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='DECIMAL' size='10,5' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='DECIMAL' size='16,5' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new BigDecimal("12345.12345") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new BigDecimal("12345.12345"), beans.get(0), "pk");
+    }
+
+    /**
+     * Tests decreasing the precision of a primary key column.
+     */
+    public void testPKColumnDecreasePrecision()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='DECIMAL' size='12,5' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='DECIMAL' size='10,5' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new BigDecimal("12345.12345") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new BigDecimal("12345.12345"), beans.get(0), "pk");
+    }
+
+    /**
+     * Tests increasing the precision of PK and FK columns.
+     */
+    public void testPKAndFKColumnIncreasePrecision()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='NUMERIC' size='8,2' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='NUMERIC' size='8,2' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='NUMERIC' size='11,2' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='NUMERIC' size='11,2' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip1", new Object[] { new BigDecimal("123456.12") });
+        insertRow("roundtrip2", new Object[] { new Integer(1), new BigDecimal("123456.12") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans1 = getRows("roundtrip1");
+        List beans2 = getRows("roundtrip2");
+
+        assertEquals(new BigDecimal("123456.12"), beans1.get(0), "pk");
+        assertEquals(new Integer(1),              beans2.get(0), "pk");
+        assertEquals(new BigDecimal("123456.12"), beans2.get(0), "fk");
+    }
+
+    /**
+     * Tests decreasing the precision of PK and FK columns.
+     */
+    public void testPKAndFKColumnDecreasePrecision()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='NUMERIC' size='10,2' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='NUMERIC' size='10,2' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='NUMERIC' size='8,2' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='NUMERIC' size='8,2' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip1", new Object[] { new BigDecimal("123456.12") });
+        insertRow("roundtrip2", new Object[] { new Integer(1), new BigDecimal("123456.12") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans1 = getRows("roundtrip1");
+        List beans2 = getRows("roundtrip2");
+
+        assertEquals(new BigDecimal("123456.12"), beans1.get(0), "pk");
+        assertEquals(new Integer(1),              beans2.get(0), "pk");
+        assertEquals(new BigDecimal("123456.12"), beans2.get(0), "fk");
+    }
+
+    /**
+     * Tests increasing the precision of an indexed column.
+     */
+    public void testIndexColumnIncreasePrecision()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DECIMAL' size='8,2'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DECIMAL' size='12,2'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new BigDecimal("123456.12"), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1),              beans.get(0), "pk");
+        assertEquals(new BigDecimal("123456.12"), beans.get(0), "avalue1");
+        assertEquals(new Integer(2),              beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests decreasing the precision of an indexed column.
+     */
+    public void testIndexColumnDecreasePrecision()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DECIMAL' size='10,2'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DECIMAL' size='8,2'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new BigDecimal("123456.12"), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1),              beans.get(0), "pk");
+        assertEquals(new BigDecimal("123456.12"), beans.get(0), "avalue1");
+        assertEquals(new Integer(2),              beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests increasing the precision of an indexed column.
+     */
+    public void testUniqueIndexColumnIncreasePrecision()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='NUMERIC' size='8,2'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='NUMERIC' size='9,2'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2), new BigDecimal("123456.12") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1),              beans.get(0), "pk");
+        assertEquals(new Integer(2),              beans.get(0), "avalue1");
+        assertEquals(new BigDecimal("123456.12"), beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests decreasing the precision of an indexed column.
+     */
+    public void testUniqueIndexColumnDecreasePrecision()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='NUMERIC' size='9,2'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='NUMERIC' size='8,2'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2), new BigDecimal("123456.12") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1),              beans.get(0), "pk");
+        assertEquals(new Integer(2),              beans.get(0), "avalue1");
+        assertEquals(new BigDecimal("123456.12"), beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests increasing the scale of a column.
+     */
+    public void testColumnIncreaseScale()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DECIMAL' size='10,4' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DECIMAL' size='10,5' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new BigDecimal("12345.1234") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0);
+
+        assertEquals(new Integer(1), bean, "pk");
+        // Some DBs return the BigDecimal with the five digits scale, some don't
+        assertTrue(bean.get("avalue").equals(new BigDecimal("12345.1234")) ||
+                   bean.get("avalue").equals(new BigDecimal("12345.12340")));
+    }
+
+    /**
+     * Tests decreasing the scale of a column.
+     */
+    public void testColumnDecreaseScale()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DECIMAL' size='10,5' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DECIMAL' size='10,3' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new BigDecimal("12345.123") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
+        assertEquals(new BigDecimal("12345.123"), beans.get(0), "avalue");
+    }
+
+    /**
+     * Tests increasing the scale of a primary key column.
+     */
+    public void testPKColumnIncreaseScale()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='NUMERIC' size='10,3' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='NUMERIC' size='10,5' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new BigDecimal("12345.123") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0);
+
+        // Some DBs return the BigDecimal with the three digits scale, some don't
+        assertTrue(bean.get("pk").equals(new BigDecimal("12345.123")) ||
+                   bean.get("pk").equals(new BigDecimal("12345.12300")));
+    }
+
+    /**
+     * Tests decreasing the scale of a primary key column.
+     */
+    public void testPKColumnDecreaseScale()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='NUMERIC' size='10,5' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='NUMERIC' size='10,3' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new BigDecimal("12345.123") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new BigDecimal("12345.123"), beans.get(0), "pk");
+    }
+
+    /**
+     * Tests increasing the scale of PK and FK columns.
+     */
+    public void testPKAndFKColumnIncreaseScale()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='DECIMAL' size='11,2' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='DECIMAL' size='11,2' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='DECIMAL' size='11,5' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='DECIMAL' size='11,5' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip1", new Object[] { new BigDecimal("123456.12") });
+        insertRow("roundtrip2", new Object[] { new Integer(1), new BigDecimal("123456.12") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List     beans1 = getRows("roundtrip1");
+        List     beans2 = getRows("roundtrip2");
+        DynaBean bean1  = (DynaBean)beans1.get(0);
+        DynaBean bean2  = (DynaBean)beans2.get(0);
+
+        // Some DBs return the BigDecimal with the three digits scale, some don't
+        assertTrue(bean1.get("pk").equals(new BigDecimal("123456.12")) ||
+                   bean1.get("pk").equals(new BigDecimal("123456.12000")));
+        assertEquals(new Integer(1),                 beans2.get(0), "pk");
+        assertTrue(bean2.get("fk").equals(new BigDecimal("123456.12")) ||
+                   bean2.get("fk").equals(new BigDecimal("123456.12000")));
+    }
+
+    /**
+     * Tests decreasing the scale of PK and FK columns.
+     */
+    public void testPKAndFKColumnDecreaseScale()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='NUMERIC' size='11,5' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='NUMERIC' size='11,5' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='NUMERIC' size='11,2' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='fk' type='NUMERIC' size='11,2' required='false'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='fk' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip1", new Object[] { new BigDecimal("123456.12") });
+        insertRow("roundtrip2", new Object[] { new Integer(1), new BigDecimal("123456.12") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans1 = getRows("roundtrip1");
+        List beans2 = getRows("roundtrip2");
+
+        assertEquals(new BigDecimal("123456.12"), beans1.get(0), "pk");
+        assertEquals(new Integer(1),              beans2.get(0), "pk");
+        assertEquals(new BigDecimal("123456.12"), beans2.get(0), "fk");
+    }
+
+    /**
+     * Tests increasing the scale of an indexed column.
+     */
+    public void testIndexColumnIncreaseScale()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='NUMERIC' size='11,2'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='NUMERIC' size='11,5'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new BigDecimal("123456.12"), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0);
+
+        assertEquals(new Integer(1), bean, "pk");
+        assertEquals(new Integer(2), bean, "avalue2");
+        assertTrue(new BigDecimal("123456.12").equals(bean.get("avalue1")) || new BigDecimal("123456.12000").equals(bean.get("avalue1")));
+    }
+
+    /**
+     * Tests decreasing the scale of an indexed column.
+     */
+    public void testIndexColumnDecreaseScale()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DECIMAL' size='11,5'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DECIMAL' size='11,2'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <index name='testindex'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "      <index-column name='avalue2'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new BigDecimal("123456.12"), new Integer(2) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1),              beans.get(0), "pk");
+        assertEquals(new BigDecimal("123456.12"), beans.get(0), "avalue1");
+        assertEquals(new Integer(2),              beans.get(0), "avalue2");
+    }
+
+    /**
+     * Tests increasing the scale of an indexed column.
+     */
+    public void testUniqueIndexColumnIncreaseScale()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='DECIMAL' size='11,2'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+
+            "    <column name='avalue2' type='DECIMAL' size='11,5'/>\n"+
+            "    <unique name='testindex'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2), new BigDecimal("123456.12") });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List     beans = getRows("roundtrip");
+        DynaBean bean  = (DynaBean)beans.get(0);
+
+        assertEquals(new Integer(1), bean, "pk");
+        assertEquals(new Integer(2), bean, "avalue1");
+        assertTrue(new BigDecimal("123456.12").equals(bean.get("avalue2")) || new BigDecimal("123456.12000").equals(bean.get("avalue2")));
+    }
+
+    /**
+     * Tests decreasing the scale of an indexed column.
+     */
+    public void testUniqueIndexColumnDecreaseScale()
+    {
+        if (!getPlatformInfo().isIndicesSupported())
+        {
+            return;
+        }
+
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER'/>\n"+

[... 2352 lines stripped ...]


Mime
View raw message