db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r711944 - in /db/ddlutils/trunk/src: main/java/org/apache/ddlutils/platform/db2/Db2Platform.java test/java/org/apache/ddlutils/io/TestInsertColumn.java
Date Thu, 06 Nov 2008 19:02:00 GMT
Author: tomdz
Date: Thu Nov  6 11:01:53 2008
New Revision: 711944

URL: http://svn.apache.org/viewvc?rev=711944&view=rev
Log:
Fixed DB2 platform

Modified:
    db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/db2/Db2Platform.java
    db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestInsertColumn.java

Modified: db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/db2/Db2Platform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/db2/Db2Platform.java?rev=711944&r1=711943&r2=711944&view=diff
==============================================================================
--- db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/db2/Db2Platform.java (original)
+++ db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/db2/Db2Platform.java Thu
Nov  6 11:01:53 2008
@@ -30,6 +30,7 @@
 import org.apache.ddlutils.alteration.RemovePrimaryKeyChange;
 import org.apache.ddlutils.alteration.TableChange;
 import org.apache.ddlutils.alteration.TableDefinitionChangesPredicate;
+import org.apache.ddlutils.model.CascadeActionEnum;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Database;
 import org.apache.ddlutils.model.Table;
@@ -75,6 +76,8 @@
         info.setIdentityColumnAutomaticallyRequired(true);
         info.setPrimaryKeyColumnsHaveToBeRequired(true);
         info.setMultipleIdentityColumnsSupported(false);
+        info.setSupportedOnUpdateActions(new CascadeActionEnum[] { CascadeActionEnum.RESTRICT,
CascadeActionEnum.NONE });
+        info.setSupportedOnDeleteActions(new CascadeActionEnum[] { CascadeActionEnum.RESTRICT,
CascadeActionEnum.CASCADE, CascadeActionEnum.SET_NULL, CascadeActionEnum.NONE });
 
         // the BINARY types are also handled by Db2Builder.getSqlType(Column)
         info.addNativeTypeMapping(Types.ARRAY,         "BLOB",                      Types.BLOB);
@@ -141,7 +144,8 @@
                     AddColumnChange addColumnChange = (AddColumnChange)change;
 
                     // DB2 cannot add IDENTITY columns, and required columns need a default
value
-                    return !addColumnChange.getNewColumn().isAutoIncrement() &&
+                    return (addColumnChange.getNextColumn() == null) &&
+                           !addColumnChange.getNewColumn().isAutoIncrement() &&
                            (!addColumnChange.getNewColumn().isRequired() || !StringUtilsExt.isEmpty(addColumnChange.getNewColumn().getDefaultValue()));
                 }
                 else

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=711944&r1=711943&r2=711944&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 Thu Nov 
6 11:01:53 2008
@@ -2473,7 +2473,7 @@
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
             "  <table name='roundtrip1'>\n"+
-            "    <column name='pk2' type='VARCHAR' size='32' primaryKey='true'/>\n"+
+            "    <column name='pk2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
             "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
             "  </table>\n"+
             "  <table name='roundtrip2'>\n"+
@@ -2607,6 +2607,11 @@
      */
     public void testInsertColumnsWithDefaultsIntoFK()
     {
+        if (getPlatformInfo().isPrimaryKeyColumnsHaveToBeRequired())
+        {
+            return;
+        }
+
         final String model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
@@ -2810,7 +2815,7 @@
             "  <table name='roundtrip1'>\n"+
             "    <column name='pk3' type='DOUBLE' primaryKey='true' required='true'/>\n"+
             "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
-            "    <column name='pk2' type='INTEGER' primaryKey='true' default='1'/>\n"+
+            "    <column name='pk2' type='INTEGER' primaryKey='true' default='1' required='true'/>\n"+
             "  </table>\n"+
             "  <table name='roundtrip2'>\n"+
             "    <column name='avalue3' type='DOUBLE' required='true'/>\n"+



Mime
View raw message