db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r711512 - in /db/ddlutils/trunk/src: main/java/org/apache/ddlutils/platform/ main/java/org/apache/ddlutils/platform/mysql/ test/java/org/apache/ddlutils/io/
Date Wed, 05 Nov 2008 05:36:24 GMT
Author: tomdz
Date: Tue Nov  4 21:36:24 2008
New Revision: 711512

URL: http://svn.apache.org/viewvc?rev=711512&view=rev
Log:
Fixed test cases for and bugs in the MySql5 platform

Modified:
    db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/CreationParameters.java
    db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java
    db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAddColumn.java
    db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAlteration.java
    db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestInsertColumn.java

Modified: db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/CreationParameters.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/CreationParameters.java?rev=711512&r1=711511&r2=711512&view=diff
==============================================================================
--- db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/CreationParameters.java (original)
+++ db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/CreationParameters.java Tue
Nov  4 21:36:24 2008
@@ -47,7 +47,7 @@
     {
         ListOrderedMap result       = new ListOrderedMap();
         Map            globalParams = (Map)_parametersPerTable.get(null);
-        Map            tableParams  = (Map)_parametersPerTable.get(table);
+        Map            tableParams  = (Map)_parametersPerTable.get(table.getName());
 
         if (globalParams != null)
         {
@@ -69,13 +69,14 @@
      */
     public void addParameter(Table table, String paramName, String paramValue)
     {
-        Map params = (Map)_parametersPerTable.get(table);
+        String key    = (table == null ? null : table.getName());
+        Map    params = (Map)_parametersPerTable.get(key);
 
         if (params == null)
         {
             // we're using a list orderered map to retain the order
             params = new ListOrderedMap();
-            _parametersPerTable.put(table, params);
+            _parametersPerTable.put(key, params);
         }
         params.put(paramName, paramValue);
     }

Modified: db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java?rev=711512&r1=711511&r2=711512&view=diff
==============================================================================
--- db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java
(original)
+++ db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java
Tue Nov  4 21:36:24 2008
@@ -138,7 +138,8 @@
                 {
                     AddColumnChange addColumnChange = (AddColumnChange)change;
 
-                    return !addColumnChange.getNewColumn().isAutoIncrement();
+                    return !addColumnChange.getNewColumn().isAutoIncrement() &&
+                           (!addColumnChange.getNewColumn().isRequired() || (addColumnChange.getNewColumn().getDefaultValue()
!= null));
                 }
                 else if (change instanceof ColumnDefinitionChange)
                 {

Modified: db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAddColumn.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAddColumn.java?rev=711512&r1=711511&r2=711512&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAddColumn.java (original)
+++ db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAddColumn.java Tue Nov  4 21:36:24
2008
@@ -443,14 +443,7 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            // MySql uses an empty string to initialize the new pk column
-            assertEquals((Object)"",     beans.get(0), "pk");
-            assertEquals(new Integer(1), beans.get(0), "avalue");
-        }
-        else if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             // Mckoi uses null to initialize the new pk column
             assertEquals((Object)null,   beans.get(0), "pk");
@@ -564,15 +557,7 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(0),  beans.get(0), "pk1");
-            assertEquals((Object)"",      beans.get(0), "pk2");
-            assertEquals(new Double(2.0), beans.get(0), "pk3");
-            assertEquals(new Integer(1),  beans.get(0), "avalue");
-        }
-        else if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals((Object)null,    beans.get(0), "pk1");
             assertEquals((Object)null,    beans.get(0), "pk2");
@@ -619,15 +604,7 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(0),  beans.get(0), "pk1");
-            assertEquals((Object)"",      beans.get(0), "pk2");
-            assertEquals(new Double(2.0), beans.get(0), "pk3");
-            assertEquals(new Integer(1),  beans.get(0), "avalue");
-        }
-        else if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals((Object)null,    beans.get(0), "pk1");
             assertEquals((Object)null,    beans.get(0), "pk2");
@@ -726,14 +703,7 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1),  beans.get(0), "pk1");
-            assertEquals(new Integer(0),  beans.get(0), "pk2");
-            assertEquals(new Integer(2),  beans.get(0), "avalue");
-        }
-        else if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk1");
             assertEquals((Object)null,   beans.get(0), "pk2");
@@ -848,15 +818,7 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1),  beans.get(0), "pk1");
-            assertEquals((Object)"",      beans.get(0), "pk2");
-            assertEquals(new Double(0.0), beans.get(0), "pk3");
-            assertEquals((Object)null,    beans.get(0), "avalue");
-        }
-        else if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (MckoiPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk1");
             assertEquals((Object)null,   beans.get(0), "pk2");
@@ -1103,14 +1065,8 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1),    beans.get(0), "pk");
-            assertEquals(new BigDecimal(0), beans.get(0), "avalue");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-                 InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk");
             assertEquals((Object)null,   beans.get(0), "avalue");
@@ -1304,15 +1260,8 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1), beans.get(0), "pk");
-            assertEquals(new Integer(1), beans.get(0), "avalue1");
-            assertEquals((Object)"",     beans.get(0), "avalue2");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-                 InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk");
             assertEquals((Object)null,   beans.get(0), "avalue1");
@@ -1455,14 +1404,7 @@
 
         List beans = getRows("roundtrip");
 
-        // TODO
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName())) 
-        {
-            assertEquals(new Integer(1),    beans.get(0), "pk");
-            assertEquals(new BigDecimal(0), beans.get(0), "avalue");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk");
             assertEquals((Object)null,   beans.get(0), "avalue");
@@ -1656,14 +1598,7 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1), beans.get(0), "pk");
-            assertEquals(new Integer(1), beans.get(0), "avalue1");
-            assertEquals((Object)"",     beans.get(0), "avalue2");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk");
             assertEquals((Object)null,   beans.get(0), "avalue1");
@@ -1717,14 +1652,7 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1), beans.get(0), "pk");
-            assertEquals(new Integer(1), beans.get(0), "avalue1");
-            assertEquals((Object)"",     beans.get(0), "avalue2");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk");
             assertEquals(new Integer(1), beans.get(0), "avalue1");
@@ -1884,15 +1812,8 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1),    beans.get(0), "pk");
-            assertEquals(new Integer(2),    beans.get(0), "avalue1");
-            assertEquals(new BigDecimal(0), beans.get(0), "avalue2");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-                 InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk");
             assertEquals(new Integer(2), beans.get(0), "avalue1");
@@ -2115,16 +2036,8 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1),  beans.get(0), "pk");
-            assertEquals(new Integer(2),  beans.get(0), "avalue1");
-            assertEquals(new Integer(3),  beans.get(0), "avalue2");
-            assertEquals(new Double(0.0), beans.get(0), "avalue3");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-                 InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            InterbasePlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk");
             assertEquals(new Integer(2), beans.get(0), "avalue1");
@@ -2287,17 +2200,7 @@
 
         List beans = getRows("roundtrip");
 
-        // TODO
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            // MySql uses the default value for the column's type to initialize
-            // the new column for existing rows
-            assertEquals(new Integer(1),    beans.get(0), "pk");
-            assertEquals(new Integer(2),    beans.get(0), "avalue1");
-            assertEquals(new BigDecimal(0), beans.get(0), "avalue2");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1), beans.get(0), "pk");
             assertEquals(new Integer(2), beans.get(0), "avalue1");
@@ -2519,15 +2422,7 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1),  beans.get(0), "pk");
-            assertEquals(new Integer(2),  beans.get(0), "avalue1");
-            assertEquals(new Integer(3),  beans.get(0), "avalue2");
-            assertEquals(new Double(0.0), beans.get(0), "avalue3");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1),  beans.get(0), "pk");
             assertEquals(new Integer(2),  beans.get(0), "avalue1");
@@ -2588,15 +2483,7 @@
 
         List beans = getRows("roundtrip");
 
-        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(1),  beans.get(0), "pk");
-            assertEquals(new Integer(2),  beans.get(0), "avalue1");
-            assertEquals(new Integer(3),  beans.get(0), "avalue2");
-            assertEquals(new Double(0.0), beans.get(0), "avalue3");
-        }
-        else if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
+        if (FirebirdPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
             assertEquals(new Integer(1),  beans.get(0), "pk");
             assertEquals(new Integer(2),  beans.get(0), "avalue1");

Modified: db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAlteration.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAlteration.java?rev=711512&r1=711511&r2=711512&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAlteration.java (original)
+++ db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestAlteration.java Tue Nov  4
21:36:24 2008
@@ -1713,13 +1713,6 @@
             assertEquals((Object)null,   beans.get(0), "pk");
             assertEquals((Object)"test", beans.get(0), "avalue");
         }
-        else if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-                 MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            // Same with MySql except it uses the default value for the datatype
-            assertEquals(new Integer(0), beans.get(0), "pk");
-            assertEquals((Object)"test", beans.get(0), "avalue");
-        }
         else
         {
             assertTrue(beans.isEmpty());

Modified: db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestInsertColumn.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestInsertColumn.java?rev=711512&r1=711511&r2=711512&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestInsertColumn.java (original)
+++ db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestInsertColumn.java Tue Nov 
4 21:36:24 2008
@@ -26,6 +26,8 @@
 
 import org.apache.commons.beanutils.DynaBean;
 import org.apache.ddlutils.TestAgainstLiveDatabaseBase;
+import org.apache.ddlutils.platform.mysql.MySql50Platform;
+import org.apache.ddlutils.platform.mysql.MySqlPlatform;
 import org.apache.ddlutils.platform.sybase.SybasePlatform;
 
 /**
@@ -328,7 +330,18 @@
         // it directly (in which case it might still be NULL)
         Object avalue = ((DynaBean)beans.get(0)).get("avalue");
 
-        assertTrue((avalue == null) || "text    ".equals(avalue));
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // MySql ignores that the type is CHAR(8) and trims the value
+            assertEquals("text", avalue);
+        }
+        else
+        {
+            // TODO
+            //assertTrue((avalue == null) || "text    ".equals(avalue));
+            assertEquals("text    ", avalue);
+        }
     }
 
     /**
@@ -403,7 +416,9 @@
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        assertTrue(getRows("roundtrip").isEmpty());
+        List beans = getRows("roundtrip");
+
+        assertTrue(beans.isEmpty());
     }
 
     /**
@@ -540,6 +555,11 @@
      */
     public void testInsertAutoIncrementColumnIntoPK()
     {
+        if (!getPlatformInfo().isMixingIdentityAndNormalPrimaryKeyColumnsSupported())
+        {
+            return;
+        }
+
         // we need special catering for Sybase which does not support identity for INTEGER
columns
         boolean      isSybase  = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
         final String model1Xml = 
@@ -602,6 +622,11 @@
      */
     public void testInsertMultipleColumnsIntoPK()
     {
+        if (!getPlatformInfo().isMixingIdentityAndNormalPrimaryKeyColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -676,6 +701,11 @@
      */
     public void testInsertNonUniqueIndexAndAutoIncrementColumn()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -788,6 +818,11 @@
      */
     public void testInsertNonUniqueIndexAndrequiredAutoIncrementColumn()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -854,9 +889,19 @@
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans = getRows("roundtrip");
+        List   beans  = getRows("roundtrip");
+        Object avalue = ((DynaBean)beans.get(0)).get("avalue");
 
-        assertEquals((Object)"text    ", beans.get(0), "avalue");
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // MySql ignores that the type is CHAR(8) and trims the value
+            assertEquals("text", avalue);
+        }
+        else
+        {
+            assertEquals("text    ", avalue);
+        }
     }
 
     /**
@@ -941,6 +986,11 @@
      */
     public void testInsertUniqueIndexAndAutoIncrementColumn()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -1053,6 +1103,11 @@
      */
     public void testInsertUniqueIndexAndRequiredAutoIncrementColumn()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -1119,9 +1174,19 @@
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans = getRows("roundtrip");
+        List   beans  = getRows("roundtrip");
+        Object avalue = ((DynaBean)beans.get(0)).get("avalue");
 
-        assertEquals((Object)"text    ", beans.get(0), "avalue");
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // MySql ignores that the type is CHAR(8) and trims the value
+            assertEquals("text", avalue);
+        }
+        else
+        {
+            assertEquals("text    ", avalue);
+        }
     }
 
     /**
@@ -1212,6 +1277,11 @@
      */
     public void testInsertAutoIncrementColumnIntoNonUniqueIndex()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -1344,6 +1414,11 @@
      */
     public void testInsertRequiredAutoIncrementColumnIntoNonUniqueIndex()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -1423,10 +1498,20 @@
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans = getRows("roundtrip");
+        List   beans   = getRows("roundtrip");
+        Object avalue2 = ((DynaBean)beans.get(0)).get("avalue2");
 
-        assertEquals(new Integer(2),     beans.get(0), "avalue1");
-        assertEquals((Object)"text    ", beans.get(0), "avalue2");
+        assertEquals(new Integer(2),  beans.get(0), "avalue1");
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // MySql ignores that the type is CHAR(8) and trims the value
+            assertEquals("text", avalue2);
+        }
+        else
+        {
+            assertEquals("text    ", avalue2);
+        }
     }
 
     /**
@@ -1523,6 +1608,11 @@
      */
     public void testInsertAutoIncrementColumnIntoUniqueIndex()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -1655,6 +1745,11 @@
      */
     public void testInsertRequiredAutoIncrementColumnIntoUniqueIndex()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -1734,10 +1829,20 @@
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans = getRows("roundtrip");
+        List   beans   = getRows("roundtrip");
+        Object avalue2 = ((DynaBean)beans.get(0)).get("avalue2");
 
-        assertEquals(new Integer(2),     beans.get(0), "avalue1");
-        assertEquals((Object)"text    ", beans.get(0), "avalue2");
+        assertEquals(new Integer(2), beans.get(0), "avalue1");
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // MySql ignores that the type is CHAR(8) and trims the value
+            assertEquals("text", avalue2);
+        }
+        else
+        {
+            assertEquals("text    ", avalue2);
+        }
     }
 
     /**
@@ -1837,6 +1942,11 @@
      */
     public void testInsertFKAndLocalAutoIncrementColumn()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -1980,6 +2090,11 @@
      */
     public void testInsertFKAndLocalRequiredAutoIncrementColumn()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -2063,12 +2178,26 @@
         assertEquals(getAdjustedModel(),
                      readModelFromDatabase("roundtriptest"));
 
-        List beans1 = getRows("roundtrip1");
-        List beans2 = getRows("roundtrip2");
+        List   beans1 = getRows("roundtrip1");
+        List   beans2 = getRows("roundtrip2");
+        Object pk1    = ((DynaBean)beans1.get(0)).get("pk");
+        Object avalue = ((DynaBean)beans2.get(0)).get("avalue");
 
-        assertEquals((Object)"text    ", beans1.get(0), "pk");
-        assertEquals(new Integer(1),    beans2.get(0), "pk");
-        assertEquals((Object)"text    ", beans2.get(0), "avalue");
+        assertEquals(new Integer(1), beans2.get(0), "pk");
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // MySql ignores that the type is CHAR(8) and trims the value
+            assertEquals("text", pk1);
+            assertEquals("text", avalue);
+        }
+        else
+        {
+            // TODO
+            //assertTrue((avalue == null) || "text    ".equals(avalue));
+            assertEquals("text    ", pk1);
+            assertEquals("text    ", avalue);
+        }
     }
 
     /**
@@ -2359,6 +2488,11 @@
      */
     public void testInsertAutoIncrementColumnIntoFK()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -2515,6 +2649,11 @@
      */
     public void testInsertRequiredAutoIncrementColumnIntoFK()
     {
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -2611,14 +2750,26 @@
 
         alterDatabase(model2Xml);
 
-        List beans1 = getRows("roundtrip1");
-        List beans2 = getRows("roundtrip2");
+        List   beans1  = getRows("roundtrip1");
+        List   beans2  = getRows("roundtrip2");
+        Object pk2     = ((DynaBean)beans1.get(0)).get("pk2");
+        Object avalue2 = ((DynaBean)beans2.get(0)).get("avalue2");
 
-        assertEquals(new Integer(1),     beans1.get(0), "pk1");
-        assertEquals((Object)"text    ", beans1.get(0), "pk2");
-        assertEquals(new Integer(2),     beans2.get(0), "pk");
-        assertEquals(new Integer(1),     beans2.get(0), "avalue1");
-        assertEquals((Object)"text    ", beans2.get(0), "avalue2");
+        assertEquals(new Integer(1), beans1.get(0), "pk1");
+        assertEquals(new Integer(2), beans2.get(0), "pk");
+        assertEquals(new Integer(1), beans2.get(0), "avalue1");
+        if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            // MySql ignores that the type is CHAR(8) and trims the value
+            assertEquals("text", pk2);
+            assertEquals("text", avalue2);
+        }
+        else
+        {
+            assertEquals("text    ", pk2);
+            assertEquals("text    ", avalue2);
+        }
     }
 
     /**



Mime
View raw message