db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r406142 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/alteration/ java/org/apache/ddlutils/platform/derby/ test/org/apache/ddlutils/alteration/ test/org/apache/ddlutils/io/
Date Sat, 13 May 2006 19:21:50 GMT
Author: tomdz
Date: Sat May 13 12:21:49 2006
New Revision: 406142

URL: http://svn.apache.org/viewcvs?rev=406142&view=rev
Log:
Enhanced model comparison
Fixed tests

Added:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java
Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java?rev=406142&r1=406141&r2=406142&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java Sat May
13 12:21:49 2006
@@ -30,41 +30,55 @@
 {
     /** The new column. */
     private Column _newColumn;
+    /** The column after which the new column should be added. */
+    private Column _previousColumn;
     /** The column before which the new column should be added. */
     private Column _nextColumn;
 
     /**
      * Creates a new change object.
      * 
-     * @param table      The table to add the column to
-     * @param nextColumn The column before which the new column should be added
-     * @param newColumn  The new column
+     * @param table          The table to add the column to
+     * @param newColumn      The new column
+     * @param previousColumn The column after which the new column should be added
+     * @param nextColumn     The column before which the new column should be added
      */
-    public AddColumnChange(Table table, Column nextColumn, Column newColumn)
+    public AddColumnChange(Table table, Column newColumn, Column previousColumn, Column nextColumn)
     {
         super(table);
-        _nextColumn = nextColumn;
-        _newColumn  = newColumn;
+        _newColumn      = newColumn;
+        _previousColumn = previousColumn;
+        _nextColumn     = nextColumn;
     }
 
     /**
-     * Returns the column before which the new column should be added.
+     * Returns the new column.
      *
-     * @return The next column
+     * @return The new column
      */
-    public Column getNextColumn()
+    public Column getNewColumn()
     {
-        return _nextColumn;
+        return _newColumn;
     }
 
     /**
-     * Returns the new column.
+     * Returns the column after which the new column should be added.
      *
-     * @return The new column
+     * @return The previous column
      */
-    public Column getNewColumn()
+    public Column getPreviousColumn()
     {
-        return _newColumn;
+        return _previousColumn;
+    }
+
+    /**
+     * Returns the column before which the new column should be added.
+     *
+     * @return The next column
+     */
+    public Column getNextColumn()
+    {
+        return _nextColumn;
     }
 
     /**

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java?rev=406142&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java Sat May 13
12:21:49 2006
@@ -0,0 +1,34 @@
+package org.apache.ddlutils.alteration;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.ddlutils.model.Column;
+
+/**
+ * Represents a change to a column of a table.
+ * 
+ * @version $Revision: $
+ */
+public interface ColumnChange extends TableChange
+{
+    /**
+     * Returns the affected column from the original model.
+     * 
+     * @return The affected column
+     */
+    public Column getChangedColumn();
+}

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java?rev=406142&r1=406141&r2=406142&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java Sat
May 13 12:21:49 2006
@@ -25,7 +25,7 @@
  * 
  * @version $Revision: $
  */
-public class ColumnDataTypeChange extends TableChangeImplBase
+public class ColumnDataTypeChange extends TableChangeImplBase implements ColumnChange
 {
     /** The column. */
     private Column _column;
@@ -51,7 +51,7 @@
      *
      * @return The column
      */
-    public Column getColumn()
+    public Column getChangedColumn()
     {
         return _column;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java?rev=406142&r1=406141&r2=406142&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java
Sat May 13 12:21:49 2006
@@ -25,7 +25,7 @@
  * 
  * @version $Revision: $
  */
-public class ColumnDefaultValueChange extends TableChangeImplBase
+public class ColumnDefaultValueChange extends TableChangeImplBase implements ColumnChange
 {
     /** The column. */
     private Column _column;
@@ -51,7 +51,7 @@
      *
      * @return The column
      */
-    public Column getColumn()
+    public Column getChangedColumn()
     {
         return _column;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java?rev=406142&r1=406141&r2=406142&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java Sat
May 13 12:21:49 2006
@@ -26,7 +26,7 @@
  * 
  * @version $Revision: $
  */
-public class ColumnRequiredChange extends TableChangeImplBase
+public class ColumnRequiredChange extends TableChangeImplBase implements ColumnChange
 {
     /** The column. */
     private Column _column;
@@ -48,7 +48,7 @@
      *
      * @return The column
      */
-    public Column getColumn()
+    public Column getChangedColumn()
     {
         return _column;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java?rev=406142&r1=406141&r2=406142&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java Sat May
13 12:21:49 2006
@@ -25,7 +25,7 @@
  * 
  * @version $Revision: $
  */
-public class ColumnSizeChange extends TableChangeImplBase
+public class ColumnSizeChange extends TableChangeImplBase implements ColumnChange
 {
     /** The column. */
     private Column _column;
@@ -55,7 +55,7 @@
      *
      * @return The column
      */
-    public Column getColumn()
+    public Column getChangedColumn()
     {
         return _column;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelChange.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelChange.java?rev=406142&r1=406141&r2=406142&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelChange.java Sat May 13
12:21:49 2006
@@ -1,7 +1,5 @@
 package org.apache.ddlutils.alteration;
 
-import org.apache.ddlutils.model.Database;
-
 /*
  * Copyright 2006 The Apache Software Foundation.
  * 
@@ -17,6 +15,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+import org.apache.ddlutils.model.Database;
 
 /**
  * Marker interface for changes to a database model element.

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java?rev=406142&r1=406141&r2=406142&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 Sat May
13 12:21:49 2006
@@ -213,8 +213,9 @@
                     _log.info("Column " + targetColumn.getName() + " needs to be created
for table " + sourceTable.getName());
                 }
                 changes.add(new AddColumnChange(sourceTable,
-                                                columnIdx < targetTable.getColumnCount()
- 1 ? targetTable.getColumn(columnIdx + 1) :null,
-                                                targetColumn));
+                                                targetColumn,
+                                                columnIdx > 0 ? targetTable.getColumn(columnIdx
- 1) : null,
+                                                columnIdx < targetTable.getColumnCount()
- 1 ? targetTable.getColumn(columnIdx + 1) :null));
             }
             else
             {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java?rev=406142&r1=406141&r2=406142&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java Sat May
13 12:21:49 2006
@@ -178,9 +178,9 @@
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("ALTER ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         print(" SET DATA TYPE VARCHAR(");
-        print(change.getColumn().getSize());
+        print(change.getChangedColumn().getSize());
         print(")");
         printEndOfStatement();
     }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java?rev=406142&r1=406141&r2=406142&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java Sat
May 13 12:21:49 2006
@@ -32,7 +32,8 @@
 {
     /**
      * Creates a new model comparator.
-     * 
+     *
+     * @param caseSensitive Whether the comparison is case sensitive 
      * @return The model comparator
      */
     protected ModelComparator createModelComparator(boolean caseSensitive)
@@ -969,7 +970,7 @@
         ColumnDataTypeChange change = (ColumnDataTypeChange)changes.get(0);
 
         assertEquals("Col",
-                     change.getColumn().getName());
+                     change.getChangedColumn().getName());
         assertEquals(Types.INTEGER,
                      change.getNewTypeCode());
     }
@@ -1006,7 +1007,7 @@
         ColumnSizeChange change = (ColumnSizeChange)changes.get(0);
 
         assertEquals("Col",
-                     change.getColumn().getName());
+                     change.getChangedColumn().getName());
         assertEquals(32,
                      change.getNewSize());
         assertEquals(0,
@@ -1045,7 +1046,7 @@
         ColumnSizeChange change = (ColumnSizeChange)changes.get(0);
 
         assertEquals("Col",
-                     change.getColumn().getName());
+                     change.getChangedColumn().getName());
         assertEquals(32,
                      change.getNewSize());
         assertEquals(5,
@@ -1117,7 +1118,7 @@
         ColumnDefaultValueChange change = (ColumnDefaultValueChange)changes.get(0);
 
         assertEquals("Col",
-                     change.getColumn().getName());
+                     change.getChangedColumn().getName());
         assertEquals("2",
                      change.getNewDefaultValue());
     }
@@ -1184,7 +1185,7 @@
         ColumnDefaultValueChange change = (ColumnDefaultValueChange)changes.get(0);
 
         assertEquals("Col",
-                     change.getColumn().getName());
+                     change.getChangedColumn().getName());
         assertEquals("0",
                      change.getNewDefaultValue());
     }
@@ -1221,7 +1222,7 @@
         ColumnRequiredChange change = (ColumnRequiredChange)changes.get(0);
 
         assertEquals("Col",
-                     change.getColumn().getName());
+                     change.getChangedColumn().getName());
     }
 
     /**

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java?rev=406142&r1=406141&r2=406142&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java Sat May 13 12:21:49
2006
@@ -304,7 +304,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='256' required='true' default='some
value'/>\n"+
+        "    <column name='avalue' type='VARCHAR' size='254' required='true' default='some
value'/>\n"+
         "  </table>\n"+
         "</database>";
     /** Test model with a simple LONGVARCHAR column. */



Mime
View raw message