db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r407558 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/alteration/ModelComparator.java java/org/apache/ddlutils/platform/SqlBuilder.java test/org/apache/ddlutils/io/TestAlteration.java
Date Thu, 18 May 2006 14:20:31 GMT
Author: tomdz
Date: Thu May 18 07:20:30 2006
New Revision: 407558

URL: http://svn.apache.org/viewvc?rev=407558&view=rev
Log:
Addec new change object for the change of the column order

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java?rev=407558&r1=407557&r2=407558&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java Thu May
18 07:20:30 2006
@@ -298,6 +298,8 @@
             }
         }
         
+        HashMap columnPosChanges = new HashMap();
+
         for (int columnIdx = 0; columnIdx < sourceTable.getColumnCount(); columnIdx++)
         {
             Column sourceColumn = sourceTable.getColumn(columnIdx);
@@ -311,6 +313,19 @@
                 }
                 changes.add(new RemoveColumnChange(sourceTable, sourceColumn));
             }
+            else
+            {
+                int targetColumnIdx = targetTable.getColumnIndex(targetColumn);
+
+                if (targetColumnIdx != columnIdx)
+                {
+                    columnPosChanges.put(sourceColumn, new Integer(targetColumnIdx));
+                }
+            }
+        }
+        if (!columnPosChanges.isEmpty())
+        {
+            changes.add(new ColumnOrderChange(sourceTable, columnPosChanges));
         }
 
         return changes;

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java?rev=407558&r1=407557&r2=407558&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java Thu May 18 07:20:30
2006
@@ -48,6 +48,7 @@
 import org.apache.ddlutils.alteration.ColumnAutoIncrementChange;
 import org.apache.ddlutils.alteration.ColumnDataTypeChange;
 import org.apache.ddlutils.alteration.ColumnDefaultValueChange;
+import org.apache.ddlutils.alteration.ColumnOrderChange;
 import org.apache.ddlutils.alteration.ColumnRequiredChange;
 import org.apache.ddlutils.alteration.ColumnSizeChange;
 import org.apache.ddlutils.alteration.ModelChange;
@@ -453,6 +454,7 @@
                                                                          PrimaryKeyChange.class,
                                                                          RemoveColumnChange.class,
                                                                          AddColumnChange.class,
+                                                                         ColumnOrderChange.class,
                                                                          ColumnAutoIncrementChange.class,
                                                                          ColumnDefaultValueChange.class,
                                                                          ColumnRequiredChange.class,

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java?rev=407558&r1=407557&r2=407558&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java Thu May 18 07:20:30
2006
@@ -492,8 +492,8 @@
 
     /**
      * Tests the addition of several columns at the end of the table. This test
-     * is known to fail on MaxDB where a DEFAULT specification is applied to existing
-     * rows even if they are not defined as NOT NULL (column 'avalue3' in the
+     * is known to fail on MaxDB and Oracle where a DEFAULT specification is applied to
+     * existing rows even if they are not defined as NOT NULL (column 'avalue3' in the
      * target schema).
      */
     public void testAddColumnsAtTheEnd()
@@ -617,7 +617,7 @@
             "  <table name='roundtrip'>\n"+
             "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
             "    <column name='avalue1' type='VARCHAR' size='32'/>\n"+
-            "    <column name='avalue4' type='CHAR' size='16'/>\n"+
+            "    <column name='avalue4' type='CHAR' size='5'/>\n"+
             "    <column name='avalue3' type='DOUBLE' default='1.0'/>\n"+
             "    <column name='avalue2' type='INTEGER'/>\n"+
             "  </table>\n"+
@@ -630,7 +630,7 @@
             "    <column name='avalue1' type='VARCHAR' size='32'/>\n"+
             "    <column name='avalue2' type='INTEGER'/>\n"+
             "    <column name='avalue3' type='DOUBLE' default='1.0'/>\n"+
-            "    <column name='avalue4' type='CHAR' size='16'/>\n"+
+            "    <column name='avalue4' type='CHAR' size='5'/>\n"+
             "  </table>\n"+
             "</database>";
 



Mime
View raw message