db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r711688 - in /db/ddlutils/trunk/src: main/java/org/apache/ddlutils/platform/hsqldb/ test/java/org/apache/ddlutils/io/
Date Wed, 05 Nov 2008 20:32:32 GMT
Author: tomdz
Date: Wed Nov  5 12:32:28 2008
New Revision: 711688

URL: http://svn.apache.org/viewvc?rev=711688&view=rev
Log:
Fixed bug in HsqlDb platform; unit test tweaks

Modified:
    db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.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/hsqldb/HsqlDbBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java?rev=711688&r1=711687&r2=711688&view=diff
==============================================================================
--- db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
(original)
+++ db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
Wed Nov  5 12:32:28 2008
@@ -26,6 +26,7 @@
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.ModelException;
 import org.apache.ddlutils.model.Table;
+import org.apache.ddlutils.model.TypeMap;
 import org.apache.ddlutils.platform.SqlBuilder;
 
 /**
@@ -155,11 +156,30 @@
         if (ColumnDefinitionChange.isTypeChanged(getPlatformInfo(), sourceColumn, targetColumn)
||
             ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn))
         {
+            boolean needSubstr = TypeMap.isTextType(targetColumn.getTypeCode()) &&
(targetColumn.getSize() != null);
+
+            if (needSubstr)
+            {
+                print("SUBSTR(");
+            }
             print("CAST(");
             printIdentifier(getColumnName(sourceColumn));
             print(" AS ");
-            print(getSqlType(targetColumn));
+            if (needSubstr)
+            {
+                print(getNativeType(targetColumn));
+            }
+            else
+            {
+                print(getSqlType(targetColumn));
+            }
             print(")");
+            if (needSubstr)
+            {
+                print(",1,");
+                print(targetColumn.getSize());
+                print(")");
+            }
         }
         else {
             super.writeCastExpression(sourceColumn, targetColumn);

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=711688&r1=711687&r2=711688&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 Wed Nov  5 12:32:28
2008
@@ -27,7 +27,6 @@
 import org.apache.commons.beanutils.DynaBean;
 import org.apache.ddlutils.TestAgainstLiveDatabaseBase;
 import org.apache.ddlutils.platform.firebird.FirebirdPlatform;
-import org.apache.ddlutils.platform.hsqldb.HsqlDbPlatform;
 import org.apache.ddlutils.platform.interbase.InterbasePlatform;
 import org.apache.ddlutils.platform.mckoi.MckoiPlatform;
 import org.apache.ddlutils.platform.mysql.MySql50Platform;
@@ -508,10 +507,6 @@
         {
             assertEquals(new BigDecimal(1), beans.get(0), "pk");
         }
-        else if (HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
-        {
-            assertEquals(new Integer(0), beans.get(0), "pk");
-        }
         else
         {
             assertEquals(new Integer(1), beans.get(0), "pk");

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=711688&r1=711687&r2=711688&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 Wed Nov  5
12:32:28 2008
@@ -181,7 +181,8 @@
      */
     public void testChangeColumnOrderWithAutoIncrementColumn()
     {
-        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported())
+        if (!getPlatformInfo().isNonPrimaryKeyIdentityColumnsSupported() ||
+            !getPlatformInfo().isMultipleIdentityColumnsSupported())
         {
             return;
         }

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=711688&r1=711687&r2=711688&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 Wed Nov 
5 12:32:28 2008
@@ -26,6 +26,7 @@
 
 import org.apache.commons.beanutils.DynaBean;
 import org.apache.ddlutils.TestAgainstLiveDatabaseBase;
+import org.apache.ddlutils.platform.hsqldb.HsqlDbPlatform;
 import org.apache.ddlutils.platform.mysql.MySql50Platform;
 import org.apache.ddlutils.platform.mysql.MySqlPlatform;
 import org.apache.ddlutils.platform.sybase.SybasePlatform;
@@ -331,9 +332,10 @@
         Object avalue = ((DynaBean)beans.get(0)).get("avalue");
 
         if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()) ||
+            HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
-            // MySql ignores that the type is CHAR(8) and trims the value
+            // Some DBs ignore that the type is CHAR(8) and trim the value
             assertEquals("text", avalue);
         }
         else
@@ -484,6 +486,11 @@
      */
     public void testAddAndInsertPKAndMultipleColumns()
     {
+        if (!getPlatformInfo().isMixingIdentityAndNormalPrimaryKeyColumnsSupported())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -893,9 +900,10 @@
         Object avalue = ((DynaBean)beans.get(0)).get("avalue");
 
         if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()) ||
+            HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
-            // MySql ignores that the type is CHAR(8) and trims the value
+            // Some DBs ignore that the type is CHAR(8) and trim the value
             assertEquals("text", avalue);
         }
         else
@@ -1178,9 +1186,10 @@
         Object avalue = ((DynaBean)beans.get(0)).get("avalue");
 
         if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()) ||
+            HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
-            // MySql ignores that the type is CHAR(8) and trims the value
+                // Some DBs ignore that the type is CHAR(8) and trim the value
             assertEquals("text", avalue);
         }
         else
@@ -1503,9 +1512,10 @@
 
         assertEquals(new Integer(2),  beans.get(0), "avalue1");
         if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()) ||
+            HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
-            // MySql ignores that the type is CHAR(8) and trims the value
+            // Some DBs ignore that the type is CHAR(8) and trim the value
             assertEquals("text", avalue2);
         }
         else
@@ -1834,9 +1844,10 @@
 
         assertEquals(new Integer(2), beans.get(0), "avalue1");
         if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()) ||
+            HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
-            // MySql ignores that the type is CHAR(8) and trims the value
+                // Some DBs ignore that the type is CHAR(8) and trim the value
             assertEquals("text", avalue2);
         }
         else
@@ -2185,9 +2196,10 @@
 
         assertEquals(new Integer(1), beans2.get(0), "pk");
         if (MySqlPlatform.DATABASENAME.equals(getPlatform().getName()) ||
-            MySql50Platform.DATABASENAME.equals(getPlatform().getName()))
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()) ||
+            HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
-            // MySql ignores that the type is CHAR(8) and trims the value
+                // Some DBs ignore that the type is CHAR(8) and trim the value
             assertEquals("text", pk1);
             assertEquals("text", avalue);
         }
@@ -2759,9 +2771,10 @@
         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()))
+            MySql50Platform.DATABASENAME.equals(getPlatform().getName()) ||
+            HsqlDbPlatform.DATABASENAME.equals(getPlatform().getName()))
         {
-            // MySql ignores that the type is CHAR(8) and trims the value
+                // Some DBs ignore that the type is CHAR(8) and trim the value
             assertEquals("text", pk2);
             assertEquals("text", avalue2);
         }



Mime
View raw message