db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r409480 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/alteration/ java/org/apache/ddlutils/platform/ java/org/apache/ddlutils/platform/db2/ java/org/apache/ddlutils/platform/derby/ java/org/apache/ddlutils/platform/firebird/ java/or...
Date Thu, 25 May 2006 21:48:08 GMT
Author: tomdz
Date: Thu May 25 14:48:07 2006
New Revision: 409480

URL: http://svn.apache.org/viewvc?rev=409480&view=rev
Log:
Fixed/enhanced Firebird platform
Added two more tests for the alteration of auto-increment columns

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.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/ColumnOrderChange.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/PrimaryKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java?rev=409480&r1=409479&r2=409480&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 Thu May 25 14:48:07 2006
@@ -108,7 +108,7 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
         Column newColumn = null;
 
@@ -121,7 +121,7 @@
             throw new DdlUtilsException(ex);
         }
 
-        Table table = database.findTable(getChangedTable().getName());
+        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
 
         if ((_previousColumn != null) && (_nextColumn != null))
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java Thu May 25 14:48:07 2006
@@ -58,14 +58,14 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
         ForeignKey newFK = null;
 
         try
         {
             newFK = (ForeignKey)_newForeignKey.clone();
-            newFK.setForeignTable(database.findTable(_newForeignKey.getForeignTableName()));
+            newFK.setForeignTable(database.findTable(_newForeignKey.getForeignTableName(), caseSensitive));
         }
         catch (CloneNotSupportedException ex)
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java Thu May 25 14:48:07 2006
@@ -56,7 +56,7 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
         Index newIndex = null;
 
@@ -68,6 +68,6 @@
         {
             throw new DdlUtilsException(ex);
         }
-        database.findTable(getChangedTable().getName()).addIndex(newIndex);
+        database.findTable(getChangedTable().getName(), caseSensitive).addIndex(newIndex);
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java Thu May 25 14:48:07 2006
@@ -55,13 +55,13 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName());
+        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
 
         for (int idx = 0; idx < _primaryKeyColumns.length; idx++)
         {
-            Column column = table.findColumn(_primaryKeyColumns[idx].getName());
+            Column column = table.findColumn(_primaryKeyColumns[idx].getName(), caseSensitive);
 
             column.setPrimaryKey(true);
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java Thu May 25 14:48:07 2006
@@ -56,7 +56,7 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
         try
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.java Thu May 25 14:48:07 2006
@@ -56,10 +56,10 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName());
-        Column column = table.findColumn(_column.getName());
+        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
+        Column column = table.findColumn(_column.getName(), caseSensitive);
 
         column.setAutoIncrement(!_column.isAutoIncrement());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java?rev=409480&r1=409479&r2=409480&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 Thu May 25 14:48:07 2006
@@ -69,10 +69,10 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName());
-        Column column = table.findColumn(_column.getName());
+        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
+        Column column = table.findColumn(_column.getName(), caseSensitive);
 
         column.setTypeCode(_newTypeCode);
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java?rev=409480&r1=409479&r2=409480&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 Thu May 25 14:48:07 2006
@@ -69,10 +69,10 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName());
-        Column column = table.findColumn(_column.getName());
+        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
+        Column column = table.findColumn(_column.getName(), caseSensitive);
 
         column.setDefaultValue(_newDefaultValue);
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnOrderChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnOrderChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnOrderChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnOrderChange.java Thu May 25 14:48:07 2006
@@ -60,9 +60,9 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table     table      = database.findTable(getChangedTable().getName());
+        Table     table      = database.findTable(getChangedTable().getName(), caseSensitive);
         ArrayList newColumns = new ArrayList(table.getColumnCount());
 
         for (int idx = 0; idx < table.getColumnCount(); idx++)

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java?rev=409480&r1=409479&r2=409480&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 Thu May 25 14:48:07 2006
@@ -56,10 +56,10 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName());
-        Column column = table.findColumn(_column.getName());
+        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
+        Column column = table.findColumn(_column.getName(), caseSensitive);
 
         column.setRequired(!_column.isRequired());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java?rev=409480&r1=409479&r2=409480&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 Thu May 25 14:48:07 2006
@@ -83,10 +83,10 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName());
-        Column column = table.findColumn(_column.getName());
+        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
+        Column column = table.findColumn(_column.getName(), caseSensitive);
 
         column.setSizeAndScale(_newSize, _newScale);
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelChange.java?rev=409480&r1=409479&r2=409480&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 Thu May 25 14:48:07 2006
@@ -28,7 +28,8 @@
     /**
      * Applies this change to the given database.
      * 
-     * @param database The database
+     * @param database      The database
+     * @param caseSensitive Whether the case of names matters
      */
-    public void apply(Database database);
+    public void apply(Database database, boolean caseSensitive);
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java Thu May 25 14:48:07 2006
@@ -69,19 +69,19 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName());
+        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
 
         for (int idx = 0; idx < _oldPrimaryKeyColumns.length; idx++)
         {
-            Column column = table.findColumn(_oldPrimaryKeyColumns[idx].getName());
+            Column column = table.findColumn(_oldPrimaryKeyColumns[idx].getName(), caseSensitive);
 
             column.setPrimaryKey(false);
         }
         for (int idx = 0; idx < _newPrimaryKeyColumns.length; idx++)
         {
-            Column column = table.findColumn(_newPrimaryKeyColumns[idx].getName());
+            Column column = table.findColumn(_newPrimaryKeyColumns[idx].getName(), caseSensitive);
 
             column.setPrimaryKey(true);
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java Thu May 25 14:48:07 2006
@@ -55,10 +55,10 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName());
-        Column column = table.findColumn(_column.getName());
+        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
+        Column column = table.findColumn(_column.getName(), caseSensitive);
 
         table.removeColumn(column);
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java Thu May 25 14:48:07 2006
@@ -57,9 +57,9 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName());
+        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
 
         table.removeForeignKey(_foreignKey);
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java Thu May 25 14:48:07 2006
@@ -55,10 +55,10 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName());
-        Index index = table.findIndex(_index.getName());
+        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
+        Index index = table.findIndex(_index.getName(), caseSensitive);
 
         table.removeIndex(index);
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java Thu May 25 14:48:07 2006
@@ -55,13 +55,13 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName());
+        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
 
         for (int idx = 0; idx < _primaryKeyColumns.length; idx++)
         {
-            Column column = table.findColumn(_primaryKeyColumns[idx].getName());
+            Column column = table.findColumn(_primaryKeyColumns[idx].getName(), caseSensitive);
 
             column.setPrimaryKey(false);
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java Thu May 25 14:48:07 2006
@@ -39,9 +39,9 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database)
+    public void apply(Database database, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName());
+        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
 
         database.removeTable(table);
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java Thu May 25 14:48:07 2006
@@ -1151,8 +1151,11 @@
 
                 for (int idx = 0; idx < autoIncrColumns.length; idx++)
                 {
-                    Object value = lastInsertedIds.getObject(autoIncrColumns[idx].getName());
-    
+                    // we're using the index rather than the name because we cannot know how
+                    // the SQL statement looks like; rather we assume that we get the values
+                    // back in the same order as the auto increment columns
+                    Object value = lastInsertedIds.getObject(idx + 1);
+
                     PropertyUtils.setProperty(dynaBean, autoIncrColumns[idx].getName(), value);
                 }
             }

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=409480&r1=409479&r2=409480&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 25 14:48:07 2006
@@ -856,7 +856,7 @@
             if (change instanceof AddPrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (AddPrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changes.clear();
             }
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java Thu May 25 14:48:07 2006
@@ -145,7 +145,7 @@
                 if (addColumnChange.getNextColumn() == null)
                 {
                     processChange(currentModel, desiredModel, addColumnChange);
-                    change.apply(currentModel);
+                    change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                     changeIt.remove();
                 }
             }
@@ -158,19 +158,19 @@
             if (change instanceof AddPrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (AddPrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (PrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof RemovePrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (RemovePrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java?rev=409480&r1=409479&r2=409480&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 Thu May 25 14:48:07 2006
@@ -135,7 +135,7 @@
                 if (addColumnChange.isAtEnd())
                 {
                     processChange(currentModel, desiredModel, addColumnChange);
-                    change.apply(currentModel);
+                    change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                     changeIt.remove();
                 }
             }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java Thu May 25 14:48:07 2006
@@ -24,9 +24,8 @@
 
 import org.apache.ddlutils.Platform;
 import org.apache.ddlutils.alteration.AddColumnChange;
-import org.apache.ddlutils.alteration.PrimaryKeyChange;
+import org.apache.ddlutils.alteration.AddPrimaryKeyChange;
 import org.apache.ddlutils.alteration.RemoveColumnChange;
-import org.apache.ddlutils.alteration.RemovePrimaryKeyChange;
 import org.apache.ddlutils.alteration.TableChange;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Database;
@@ -44,9 +43,6 @@
  */
 public class FirebirdBuilder extends SqlBuilder
 {
-    /** Denotes the string used via SET TERM for delimiting commands that need to be executed in one go. */
-    public static final String TERM_COMMAND = "--TERM--";
-
     /**
      * Creates a new builder instance.
      * 
@@ -70,61 +66,80 @@
 
         for (int idx = 0; idx < columns.length; idx++)
         {
-            print("CREATE GENERATOR ");
-            printIdentifier(getGeneratorName(table, columns[idx]));
-            printEndOfStatement();
-            print(TERM_COMMAND);
-            printEndOfStatement();
-            print("CREATE TRIGGER ");
-            printIdentifier(getConstraintName("trg", table, columns[idx].getName(), null));
-            print(" FOR ");
-            printlnIdentifier(getTableName(table));
-            println("ACTIVE BEFORE INSERT POSITION 0 AS");
-            println("BEGIN");
-            print("IF (NEW.");
-            printIdentifier(getColumnName(columns[idx]));
-            println(" IS NULL) THEN");
-            print("NEW.");
-            printIdentifier(getColumnName(columns[idx]));
-            print(" = GEN_ID(");
-            printIdentifier(getGeneratorName(table, columns[idx]));
-            println(", 1);");
-            println("END;");
-            print(TERM_COMMAND);
-            printEndOfStatement();
+            writeAutoIncrementCreateStmts(database, table, columns[idx]);
         }
     }
 
     /**
-     * Determines the name of the generator for an auto-increment column.
-     * 
-     * @param table  The table
-     * @param column The auto-increment column
-     * @return The generator name
-     */
-    protected String getGeneratorName(Table table, Column column)
-    {
-    	return getConstraintName("gen", table, column.getName(), null);
-    }
-    
-    /**
      * {@inheritDoc}
      */
     public void dropTable(Table table) throws IOException
     {
-        super.dropTable(table);
         // dropping generators for auto-increment
         Column[] columns = table.getAutoIncrementColumns();
 
         for (int idx = 0; idx < columns.length; idx++)
         {
-            print("DROP TRIGGER ");
-            printIdentifier(getConstraintName("trg", table, columns[idx].getName(), null));
-            printEndOfStatement();
-            print("DROP GENERATOR ");
-            printIdentifier(getGeneratorName(table, columns[idx]));
-            printEndOfStatement();
+            writeAutoIncrementDropStmts(table, columns[idx]);
         }
+        super.dropTable(table);
+    }
+
+    /**
+     * Writes the creation statements to make the given column an auto-increment column.
+     * 
+     * @param database The database model
+     * @param table    The table
+     * @param column   The column to make auto-increment
+     */
+    private void writeAutoIncrementCreateStmts(Database database, Table table, Column column) throws IOException
+    {
+        print("CREATE GENERATOR ");
+        printIdentifier(getGeneratorName(table, column));
+        printEndOfStatement();
+
+        print("CREATE TRIGGER ");
+        printIdentifier(getConstraintName("trg", table, column.getName(), null));
+        print(" FOR ");
+        printlnIdentifier(getTableName(table));
+        println("ACTIVE BEFORE INSERT POSITION 0 AS");
+        print("BEGIN IF (NEW.");
+        printIdentifier(getColumnName(column));
+        print(" IS NULL) THEN NEW.");
+        printIdentifier(getColumnName(column));
+        print(" = GEN_ID(");
+        printIdentifier(getGeneratorName(table, column));
+        print(", 1); END");
+        printEndOfStatement();
+    }
+
+    /**
+     * Writes the statements to drop the auto-increment status for the given column.
+     * 
+     * @param table  The table
+     * @param column The column to remove the auto-increment status for
+     */
+    private void writeAutoIncrementDropStmts(Table table, Column column) throws IOException
+    {
+        print("DROP TRIGGER ");
+        printIdentifier(getConstraintName("trg", table, column.getName(), null));
+        printEndOfStatement();
+
+        print("DROP GENERATOR ");
+        printIdentifier(getGeneratorName(table, column));
+        printEndOfStatement();
+    }
+
+    /**
+     * Determines the name of the generator for an auto-increment column.
+     * 
+     * @param table  The table
+     * @param column The auto-increment column
+     * @return The generator name
+     */
+    protected String getGeneratorName(Table table, Column column)
+    {
+    	return getConstraintName("gen", table, column.getName(), null);
     }
 
     /**
@@ -151,14 +166,14 @@
         {
             StringBuffer result = new StringBuffer();
     
+            result.append("SELECT ");
             for (int idx = 0; idx < columns.length; idx++)
             {
-                result.append("SELECT GEN_ID (");
+                result.append("GEN_ID(");
                 result.append(getConstraintName("gen", table, columns[idx].getName(), null));
-                result.append(",0 ) FROM RDB$DATABASE");
-                result.append(table.getName());
-                result.append(getDelimitedIdentifier(columns[idx].getName()));
+                result.append(", 0)");
             }
+            result.append(" FROM RDB$DATABASE");
             return result.toString();
         }
     }
@@ -208,64 +223,62 @@
      */
     protected void processTableStructureChanges(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, Map parameters, List changes) throws IOException
     {
-        // First we drop primary keys as necessary
+    	// TODO: Dropping of primary keys is currently not supported because we cannot
+    	//       determine the pk constraint names and drop them in one go
+    	//       (We could used a stored procedure if Firebird would allow them to use DDL)
+    	//       This will be easier once named primary keys are supported
+        boolean pkColumnAdded = false;
+
         for (Iterator changeIt = changes.iterator(); changeIt.hasNext();)
         {
             TableChange change = (TableChange)changeIt.next();
 
-            if (change instanceof RemovePrimaryKeyChange)
+            if (change instanceof AddColumnChange)
             {
-                processChange(currentModel, desiredModel, (RemovePrimaryKeyChange)change);
-                change.apply(currentModel);
-                changeIt.remove();
+            	AddColumnChange addColumnChange = (AddColumnChange)change;
+
+            	// TODO: we cannot add columns to the primary key this way
+            	//       because we would have to drop the pk first and then
+            	//       add a new one afterwards which is not supported yet
+            	if (addColumnChange.getNewColumn().isPrimaryKey())
+                {
+                    pkColumnAdded = true;   
+                }
+                else
+            	{
+	            	processChange(currentModel, desiredModel, addColumnChange);
+	                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
+	                changeIt.remove();
+            	}
             }
-            else if (change instanceof PrimaryKeyChange)
+            else if (change instanceof RemoveColumnChange)
             {
-                PrimaryKeyChange       pkChange       = (PrimaryKeyChange)change;
-                RemovePrimaryKeyChange removePkChange = new RemovePrimaryKeyChange(pkChange.getChangedTable(),
-                                                                                   pkChange.getOldPrimaryKeyColumns());
+            	RemoveColumnChange removeColumnChange = (RemoveColumnChange)change;
 
-                processChange(currentModel, desiredModel, removePkChange);
-                removePkChange.apply(currentModel);
+            	// TODO: we cannot drop primary key columns this way
+            	//       because we would have to drop the pk first and then
+            	//       add a new one afterwards which is not supported yet
+            	if (!removeColumnChange.getColumn().isPrimaryKey())
+            	{
+	            	processChange(currentModel, desiredModel, removeColumnChange);
+	                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
+	                changeIt.remove();
+            	}
             }
         }
-
         for (Iterator changeIt = changes.iterator(); changeIt.hasNext();)
         {
             TableChange change = (TableChange)changeIt.next();
 
-            if (change instanceof AddColumnChange)
-            {
-                processChange(currentModel, desiredModel, (AddColumnChange)change);
-                change.apply(currentModel);
-                changeIt.remove();
-            }
-            else if (change instanceof RemoveColumnChange)
+            // we can only add a primary key if all columns are present in the table
+            // i.e. none was added during this alteration
+            if ((change instanceof AddPrimaryKeyChange) && !pkColumnAdded)
             {
-                processChange(currentModel, desiredModel, (RemoveColumnChange)change);
-                change.apply(currentModel);
+                processChange(currentModel, desiredModel, (AddPrimaryKeyChange)change);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
         }
-        super.processTableStructureChanges(currentModel, desiredModel, sourceTable, targetTable, parameters, changes);
-    }
-
-    /**
-     * Processes the removal of a primary key from a table.
-     * 
-     * @param currentModel The current database schema
-     * @param desiredModel The desired database schema
-     * @param change       The change object
-     */
-    protected void processChange(Database               currentModel,
-                                 Database               desiredModel,
-                                 RemovePrimaryKeyChange change) throws IOException
-    {
-        print("ALTER TABLE ");
-        printlnIdentifier(getTableName(change.getChangedTable()));
-        printIndent();
-        print("DROP PRIMARY KEY");
-        printEndOfStatement();
     }
 
     /**
@@ -286,11 +299,17 @@
         writeColumn(change.getChangedTable(), change.getNewColumn());
         printEndOfStatement();
 
+        Table curTable = currentModel.findTable(change.getChangedTable().getName(), getPlatform().isDelimitedIdentifierModeOn());
+
         if (!change.isAtEnd())
         {
-            Table  curTable   = currentModel.findTable(change.getChangedTable().getName(), getPlatform().isDelimitedIdentifierModeOn());
             Column prevColumn = change.getPreviousColumn();
 
+            if (prevColumn != null)
+            {
+            	// we need the corresponding column object from the current table
+            	prevColumn = curTable.findColumn(prevColumn.getName(), getPlatform().isDelimitedIdentifierModeOn());
+            }
             // Even though Firebird can only add columns, we can move them later on
             print("ALTER TABLE ");
             printlnIdentifier(getTableName(change.getChangedTable()));
@@ -298,9 +317,14 @@
             print("ALTER ");
             printIdentifier(getColumnName(change.getNewColumn()));
             print(" POSITION ");
-            print(prevColumn == null ? "0" : String.valueOf(curTable.getColumnIndex(prevColumn)));
+            // column positions start at 1 in Firebird
+            print(prevColumn == null ? "1" : String.valueOf(curTable.getColumnIndex(prevColumn) + 2));
             printEndOfStatement();
         }
+        if (change.getNewColumn().isAutoIncrement())
+        {
+            writeAutoIncrementCreateStmts(currentModel, curTable, change.getNewColumn());
+        }
     }
 
     /**
@@ -314,6 +338,10 @@
                                  Database           desiredModel,
                                  RemoveColumnChange change) throws IOException
     {
+        if (change.getColumn().isAutoIncrement())
+        {
+            writeAutoIncrementDropStmts(change.getChangedTable(), change.getColumn());
+        }
         print("ALTER TABLE ");
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java Thu May 25 14:48:07 2006
@@ -170,7 +170,8 @@
 
             while (rs.next())
             {
-                Column column = (Column)names.get(rs.getString(1).trim());
+                String generatorName = rs.getString(1).trim();
+                Column column        = (Column)names.get(generatorName);
 
                 if (column != null)
                 {
@@ -330,8 +331,10 @@
 	 */
 	protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table, Index index)
 	{
-		// Firebird generates an unique index for the pks of the form "RDB$PRIMARY825"
-		return index.getName().startsWith("RDB$PRIMARY");
+        // In Firebird, primary keys can only be determined from a live database by looking for
+        // unique indexes that cover the primary key columns
+		// These checks however already have been done when DdlUtils enters this method 
+		return true;
 	}
 
 	/**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java Thu May 25 14:48:07 2006
@@ -16,16 +16,8 @@
  * limitations under the License.
  */
 
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.Statement;
 import java.sql.Types;
-import java.util.StringTokenizer;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ddlutils.DynaSqlException;
 import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.platform.PlatformImplBase;
 
@@ -45,8 +37,6 @@
     public static final String JDBC_DRIVER      = "org.firebirdsql.jdbc.FBDriver";
     /** The subprotocol used by the standard Firebird driver. */
     public static final String JDBC_SUBPROTOCOL = "firebirdsql";
-    /** The log for this platform. */
-    private final Log _log = LogFactory.getLog(getClass());
 
     /**
      * Creates a new Firebird platform instance.
@@ -100,120 +90,4 @@
     {
         return DATABASENAME;
     }
-
-    /**
-     * Firebird-specific replacement for
-     * {@link org.apache.ddlutils.platform.PlatformImplBase#evaluateBatch(Connection, String, boolean)}
-     * that executes blocks delimited by the term {@link FirebirdBuilder#TERM_COMMAND}
-     * (defined in the database via <code>SET TERM !!;</code>), in one go.
-     *
-     * @param connection      The connection to use
-     * @param sql             The sql to process
-     * @param continueOnError Whether to continue when an error occurs
-     * @return The number of errors
-     */
-    public int evaluateBatch(Connection connection, String sql, boolean continueOnError) throws DynaSqlException
-    {
-        Statement statement    = null;
-        int       commandCount = 0;
-        int       errors       = 0;
-
-        try
-        {
-            statement = connection.createStatement();
-
-            StringTokenizer tokenizer = new StringTokenizer(sql, ";");
-            StringBuffer    command   = new StringBuffer();
-    
-            while (tokenizer.hasMoreTokens())
-            {
-                String token = tokenizer.nextToken().trim();
-
-                command.setLength(0);
-
-                if (token.equals(FirebirdBuilder.TERM_COMMAND))
-                {
-                    while (tokenizer.hasMoreTokens())
-                    {
-                        token = tokenizer.nextToken().trim();  
-
-                        if (token.length() > 0)
-                        {
-                            if (token.equals(FirebirdBuilder.TERM_COMMAND))
-                            {
-                                break;
-                            }
-                            else
-                            {
-                                command.append(token);
-                                command.append(";");
-                            }
-                        }
-                        
-                    }
-                }
-                else
-                {
-                    command.append(token);
-                }
-                if (command.length() == 0)
-                {
-                    continue;
-                }
-                
-                commandCount++;
-                
-                if (_log.isDebugEnabled())
-                {
-                    _log.debug("About to execute SQL " + command.toString());
-                }
-                try
-                {
-                    int results = statement.executeUpdate(command.toString());
-
-                    if (_log.isDebugEnabled())
-                    {
-                        _log.debug("After execution, " + results + " row(s) have been changed");
-                    }
-                }
-                catch (SQLException ex)
-                {
-                    if (continueOnError)
-                    {
-                        _log.error("SQL Command " + command.toString() + " failed", ex);
-                        errors++;
-                    }
-                    else
-                    {
-                        throw new DynaSqlException("Error while executing SQL "+command, ex);
-                    }
-                }
-
-                // lets display any warnings
-                SQLWarning warning = connection.getWarnings();
-
-                while (warning != null)
-                {
-                    _log.warn(warning.toString());
-                    warning = warning.getNextWarning();
-                }
-                connection.clearWarnings();
-            }
-            if (_log.isInfoEnabled())
-            {
-                _log.info("Executed "+ commandCount + " SQL command(s) with " + errors + " error(s)");
-            }
-        }
-        catch (SQLException ex)
-        {
-            throw new DynaSqlException("Error while executing SQL", ex);
-        }
-        finally
-        {
-            closeStatement(statement);
-        }
-
-        return errors;
-    }
-
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java Thu May 25 14:48:07 2006
@@ -102,7 +102,7 @@
             AddColumnChange addColumnChange = (AddColumnChange)changeIt.previous();
 
             processChange(currentModel, desiredModel, addColumnChange);
-            addColumnChange.apply(currentModel);
+            addColumnChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
             changeIt.remove();
         }
 
@@ -118,7 +118,7 @@
                 if (!removeColumnChange.getColumn().isPrimaryKey())
                 {
                     processChange(currentModel, desiredModel, removeColumnChange);
-                    change.apply(currentModel);
+                    change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                     changeIt.remove();
                 }
             }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java Thu May 25 14:48:07 2006
@@ -329,7 +329,7 @@
             if (change instanceof RemovePrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (RemovePrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
@@ -339,7 +339,7 @@
                                                                                    pkChange.getOldPrimaryKeyColumns());
 
                 processChange(currentModel, desiredModel, removePkChange);
-                removePkChange.apply(currentModel);
+                removePkChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
             }
         }
 
@@ -359,14 +359,14 @@
                 if (addColumnChange.isAtEnd())
                 {
                     processChange(currentModel, desiredModel, addColumnChange);
-                    change.apply(currentModel);
+                    change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                     changeIt.remove();
                 }
             }
             else if (change instanceof RemoveColumnChange)
             {
                 processChange(currentModel, desiredModel, (RemoveColumnChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof ColumnAutoIncrementChange)
@@ -399,7 +399,7 @@
                     processedColumns.add(targetColumn);
                 }
                 changes.remove(change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
             }
         }
         // Finally we add primary keys
@@ -410,7 +410,7 @@
             if (change instanceof AddPrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (AddPrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
@@ -420,7 +420,7 @@
                                                                           pkChange.getNewPrimaryKeyColumns());
 
                 processChange(currentModel, desiredModel, addPkChange);
-                addPkChange.apply(currentModel);
+                addPkChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java Thu May 25 14:48:07 2006
@@ -188,7 +188,7 @@
             AddColumnChange addColumnChange = (AddColumnChange)changeIt.next();
 
             processChange(currentModel, desiredModel, addColumnChange);
-            addColumnChange.apply(currentModel);
+            addColumnChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
             changeIt.remove();
         }
 
@@ -203,25 +203,25 @@
             if (change instanceof RemoveColumnChange)
             {
                 processChange(currentModel, desiredModel, (RemoveColumnChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof AddPrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (AddPrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (PrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof RemovePrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (RemovePrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java Thu May 25 14:48:07 2006
@@ -278,7 +278,7 @@
             if (change instanceof RemovePrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (RemovePrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
@@ -288,7 +288,7 @@
                                                                                    pkChange.getOldPrimaryKeyColumns());
 
                 processChange(currentModel, desiredModel, removePkChange);
-                removePkChange.apply(currentModel);
+                removePkChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
             }
         }
 
@@ -307,14 +307,14 @@
                 if (addColumnChange.isAtEnd())
                 {
                     processChange(currentModel, desiredModel, addColumnChange);
-                    change.apply(currentModel);
+                    change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                     changeIt.remove();
                 }
             }
             else if (change instanceof RemoveColumnChange)
             {
                 processChange(currentModel, desiredModel, (RemoveColumnChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
         }
@@ -326,7 +326,7 @@
             if (change instanceof AddPrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (AddPrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
@@ -336,7 +336,7 @@
                                                                           pkChange.getNewPrimaryKeyColumns());
 
                 processChange(currentModel, desiredModel, addPkChange);
-                addPkChange.apply(currentModel);
+                addPkChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java Thu May 25 14:48:07 2006
@@ -191,14 +191,14 @@
                     (addColumnChange.getNextColumn() == null))
                 {
                     processChange(currentModel, desiredModel, addColumnChange);
-                    change.apply(currentModel);
+                    change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                     changeIt.remove();
                 }
             }
             else if (change instanceof RemoveColumnChange)
             {
                 processChange(currentModel, desiredModel, (RemoveColumnChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java Thu May 25 14:48:07 2006
@@ -92,7 +92,7 @@
             if (change instanceof RemovePrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (RemovePrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
@@ -102,7 +102,7 @@
                                                                                    pkChange.getOldPrimaryKeyColumns());
 
                 processChange(currentModel, desiredModel, removePkChange);
-                removePkChange.apply(currentModel);
+                removePkChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
             }
         }
         // Next we add/change/remove columns
@@ -120,26 +120,26 @@
                 if (addColumnChange.isAtEnd())
                 {
                     processChange(currentModel, desiredModel, addColumnChange);
-                    change.apply(currentModel);
+                    change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                     changeIt.remove();
                 }
             }
             else if (change instanceof ColumnDefaultValueChange)
             {
                 processChange(currentModel, desiredModel, (ColumnDefaultValueChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof ColumnRequiredChange)
             {
                 processChange(currentModel, desiredModel, (ColumnRequiredChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof RemoveColumnChange)
             {
                 processChange(currentModel, desiredModel, (RemoveColumnChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
         }
@@ -151,7 +151,7 @@
             if (change instanceof AddPrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (AddPrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
@@ -161,7 +161,7 @@
                                                                           pkChange.getNewPrimaryKeyColumns());
 
                 processChange(currentModel, desiredModel, addPkChange);
-                addPkChange.apply(currentModel);
+                addPkChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java Thu May 25 14:48:07 2006
@@ -278,7 +278,7 @@
             if (change instanceof RemovePrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (RemovePrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
@@ -288,7 +288,7 @@
                                                                                    pkChange.getOldPrimaryKeyColumns());
 
                 processChange(currentModel, desiredModel, removePkChange);
-                removePkChange.apply(currentModel);
+                removePkChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
             }
         }
 
@@ -308,14 +308,14 @@
                 if (addColumnChange.isAtEnd())
                 {
                     processChange(currentModel, desiredModel, addColumnChange);
-                    change.apply(currentModel);
+                    change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                     changeIt.remove();
                 }
             }
             else if (change instanceof RemoveColumnChange)
             {
                 processChange(currentModel, desiredModel, (RemoveColumnChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof ColumnAutoIncrementChange)
@@ -366,7 +366,7 @@
                 }
                 for (Iterator changeIt = changesPerColumn.iterator(); changeIt.hasNext();)
                 {
-                    ((ColumnChange)changeIt.next()).apply(currentModel);
+                    ((ColumnChange)changeIt.next()).apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 }
             }
         }
@@ -378,7 +378,7 @@
             if (change instanceof AddPrimaryKeyChange)
             {
                 processChange(currentModel, desiredModel, (AddPrimaryKeyChange)change);
-                change.apply(currentModel);
+                change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
             else if (change instanceof PrimaryKeyChange)
@@ -388,7 +388,7 @@
                                                                           pkChange.getNewPrimaryKeyColumns());
 
                 processChange(currentModel, desiredModel, addPkChange);
-                addPkChange.apply(currentModel);
+                addPkChange.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
                 changeIt.remove();
             }
         }

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=409480&r1=409479&r2=409480&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 25 14:48:07 2006
@@ -449,6 +449,46 @@
     }
 
     /**
+     * Tests the addition of an auto-increment column.
+     */
+    public void testAddAutoIncrementColumn()
+    {
+    	if (!getPlatformInfo().isNonPKIdentityColumnsSupported())
+    	{
+    		return;
+    	}
+
+    	final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' autoIncrement='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
+
+    	alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "avalue");
+    }
+
+    /**
      * Tests the addition of several columns.
      */
     public void testAddColumns()
@@ -678,6 +718,41 @@
         createDatabase(model1Xml);
 
         insertRow("roundtrip", new Object[] { new Integer(1), "test" });
+
+    	alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
+    }
+
+    /**
+     * Tests the removal of an auto-increment column.
+     */
+    public void testDropAutoIncrementColumn()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' autoIncrement='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+        final String model2Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
 
     	alterDatabase(model2Xml);
 

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java?rev=409480&r1=409479&r2=409480&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java Thu May 25 14:48:07 2006
@@ -95,9 +95,11 @@
     public void testColumnConstraints() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE \"constraints\";\n"+
+            "DROP TRIGGER \"trg_constraints_OL_PK_AUTO_INCR\";\n" +
             "DROP GENERATOR \"gen_constraints_OL_PK_AUTO_INCR\";\n" +
+            "DROP TRIGGER \"trg_constraints_COL_AUTO_INCR\";\n" +
             "DROP GENERATOR \"gen_constraints_COL_AUTO_INCR\";\n" +
+            "DROP TABLE \"constraints\";\n"+
             "CREATE TABLE \"constraints\"\n"+
             "(\n"+
             "    \"COL_PK\"               VARCHAR(32),\n"+
@@ -109,23 +111,13 @@
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n"+
             "CREATE GENERATOR \"gen_constraints_OL_PK_AUTO_INCR\";\n" +
-            "--TERM--;\n"+
             "CREATE TRIGGER \"trg_constraints_OL_PK_AUTO_INCR\" FOR \"constraints\"\n"+
             "ACTIVE BEFORE INSERT POSITION 0 AS\n"+
-            "BEGIN\n"+
-            "  IF (NEW.\"COL_PK_AUTO_INCR\" IS NULL) THEN\n"+
-            "    NEW.\"COL_PK_AUTO_INCR\" = GEN_ID(\"gen_constraints_OL_PK_AUTO_INCR\", 1);\n"+
-            "END;\n"+
-            "--TERM--;\n"+
+            "BEGIN IF (NEW.\"COL_PK_AUTO_INCR\" IS NULL) THEN NEW.\"COL_PK_AUTO_INCR\" = GEN_ID(\"gen_constraints_OL_PK_AUTO_INCR\", 1); END;\n"+
             "CREATE GENERATOR \"gen_constraints_COL_AUTO_INCR\";\n" +
-            "--TERM--;\n"+
             "CREATE TRIGGER \"trg_constraints_COL_AUTO_INCR\" FOR \"constraints\"\n"+
             "ACTIVE BEFORE INSERT POSITION 0 AS\n"+
-            "BEGIN\n"+
-            "  IF (NEW.\"COL_AUTO_INCR\" IS NULL) THEN\n"+
-            "    NEW.\"COL_AUTO_INCR\" = GEN_ID(\"gen_constraints_COL_AUTO_INCR\", 1);\n"+
-            "END;\n"+
-            "--TERM--;\n",
+            "BEGIN IF (NEW.\"COL_AUTO_INCR\" IS NULL) THEN NEW.\"COL_AUTO_INCR\" = GEN_ID(\"gen_constraints_COL_AUTO_INCR\", 1); END;\n",
             createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
     }
 



Mime
View raw message