db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r406163 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/platform/ java/org/apache/ddlutils/platform/db2/ java/org/apache/ddlutils/platform/derby/ java/org/apache/ddlutils/platform/firebird/ java/org/apache/ddlutils/platform/hsqldb/ ja...
Date Sat, 13 May 2006 23:16:47 GMT
Author: tomdz
Date: Sat May 13 16:16:45 2006
New Revision: 406163

URL: http://svn.apache.org/viewcvs?rev=406163&view=rev
Log:
Switched platforms to new alteration algorithm
Enhanced alteration algorithm for DB2
Enhanced model readers so that the system index determination now has access to the database
meta data
Fixed tests

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySql50ModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java Sat May 13
16:16:45 2006
@@ -200,6 +200,8 @@
         result.add(new MetaDataColumnDescriptor("COLUMN_NAME", Types.VARCHAR));
         // we're also reading the table name so that a model reader impl can filter manually
         result.add(new MetaDataColumnDescriptor("TABLE_NAME",  Types.VARCHAR));
+        // the name of the primary key is currently only interesting to the pk index name
resolution
+        result.add(new MetaDataColumnDescriptor("PK_NAME",  Types.VARCHAR));
 
         return result;
     }
@@ -552,7 +554,7 @@
 
             if (getPlatformInfo().isSystemIndicesReturned())
             {
-                removeSystemIndices(table);
+                removeSystemIndices(metaData, table);
             }
         }
         return table;
@@ -563,24 +565,26 @@
      * Removes system indices (generated by the database for primary and foreign keys)
      * from the table.
      * 
-     * @param table The table
+     * @param metaData The database meta data
+     * @param table    The table
      */
-    protected void removeSystemIndices(Table table)
+    protected void removeSystemIndices(DatabaseMetaDataWrapper metaData, Table table) throws
SQLException
     {
-        removeInternalPrimaryKeyIndex(table);
+        removeInternalPrimaryKeyIndex(metaData, table);
 
         for (int fkIdx = 0; fkIdx < table.getForeignKeyCount(); fkIdx++)
         {
-            removeInternalForeignKeyIndex(table, table.getForeignKey(fkIdx));
+            removeInternalForeignKeyIndex(metaData, table, table.getForeignKey(fkIdx));
         }
     }
 
     /**
      * Tries to remove the internal index for the table's primary key.
      * 
-     * @param table The table
+     * @param metaData The database meta data
+     * @param table    The table
      */
-    protected void removeInternalPrimaryKeyIndex(Table table)
+    protected void removeInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table
table) throws SQLException
     {
         Column[] pks         = table.getPrimaryKeyColumns();
         List     columnNames = new ArrayList();
@@ -595,7 +599,7 @@
             Index index = table.getIndex(indexIdx);
 
             if (index.isUnique() && matches(index, columnNames) && 
-                isInternalPrimaryKeyIndex(table, index))
+                isInternalPrimaryKeyIndex(metaData, table, index))
             {
                 table.removeIndex(indexIdx);
                 break;
@@ -606,10 +610,11 @@
     /**
      * Tries to remove the internal index for the given foreign key.
      * 
-     * @param table The table where the table is defined
-     * @param fk    The foreign key
+     * @param metaData The database meta data
+     * @param table    The table where the table is defined
+     * @param fk       The foreign key
      */
-    protected void removeInternalForeignKeyIndex(Table table, ForeignKey fk)
+    protected void removeInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table
table, ForeignKey fk) throws SQLException
     {
         List columnNames = new ArrayList();
 
@@ -623,7 +628,7 @@
             Index index = table.getIndex(indexIdx);
 
             if (!index.isUnique() && matches(index, columnNames) && 
-                isInternalForeignKeyIndex(table, fk, index))
+                isInternalForeignKeyIndex(metaData, table, fk, index))
             {
                 table.removeIndex(indexIdx);
                 break;
@@ -661,11 +666,12 @@
      * Redefine this method for specific platforms if there are better ways
      * to determine internal indices.
      * 
-     * @param table The table owning the index
-     * @param index The index to check
+     * @param metaData The database meta data
+     * @param table    The table owning the index
+     * @param index    The index to check
      * @return <code>true</code> if the index seems to be an internal primary
key one
      */
-    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+    protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
Index index) throws SQLException
     {
         return false;
     }
@@ -677,12 +683,13 @@
      * Redefine this method for specific platforms if there are better ways
      * to determine internal indices.
      * 
-     * @param table The table owning the index and foreign key
-     * @param fk    The foreign key
-     * @param index The index to check
+     * @param metaData The database meta data
+     * @param table    The table owning the index and foreign key
+     * @param fk       The foreign key
+     * @param index    The index to check
      * @return <code>true</code> if the index seems to be an internal primary
key one
      */
-    protected boolean isInternalForeignKeyIndex(Table table, ForeignKey fk, Index index)
+    protected boolean isInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
ForeignKey fk, Index index) throws SQLException
     {
         return false;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java?rev=406163&r1=406162&r2=406163&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 Sat May
13 16:16:45 2006
@@ -529,7 +529,8 @@
             StringWriter buffer = new StringWriter();
 
             getSqlBuilder().setWriter(buffer);
-            getSqlBuilder().alterDatabase(currentModel, desiredModel, doDrops, modifyColumns);
+            //getSqlBuilder().alterDatabase(currentModel, desiredModel, doDrops, modifyColumns);
+            getSqlBuilder().alterDatabase2(currentModel, desiredModel, null);
             sql = buffer.toString();
         }
         catch (IOException ex)
@@ -562,7 +563,8 @@
             StringWriter buffer = new StringWriter();
 
             getSqlBuilder().setWriter(buffer);
-            getSqlBuilder().alterDatabase(currentModel, desiredModel, params, doDrops, modifyColumns);
+            //getSqlBuilder().alterDatabase(currentModel, desiredModel, params, doDrops,
modifyColumns);
+            getSqlBuilder().alterDatabase2(currentModel, desiredModel, params);
             sql = buffer.toString();
         }
         catch (IOException ex)
@@ -1824,7 +1826,7 @@
         {
             value = resultSet.getObject(columnName);
         }
-        return value;
+        return resultSet.wasNull() ? null : value;
     }
 
 	/**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java?rev=406163&r1=406162&r2=406163&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 Sat May 13
16:16:45 2006
@@ -18,10 +18,22 @@
 
 import java.io.IOException;
 import java.sql.Types;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.ddlutils.Platform;
+import org.apache.ddlutils.alteration.AddColumnChange;
+import org.apache.ddlutils.alteration.AddPrimaryKeyChange;
+import org.apache.ddlutils.alteration.PrimaryKeyChange;
+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;
+import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Table;
+import org.apache.ddlutils.model.TypeMap;
 import org.apache.ddlutils.platform.SqlBuilder;
 import org.apache.ddlutils.util.Jdbc3Utils;
 
@@ -67,5 +79,175 @@
     protected void writeColumnAutoIncrementStmt(Table table, Column column) throws IOException
     {
         print("GENERATED BY DEFAULT AS IDENTITY");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void writeExternalIndexDropStmt(Table table, Index index) throws IOException
+    {
+        // Index names in DB2 are unique to a schema and hence Derby does not
+        // use the ON <tablename> clause
+        print("DROP INDEX ");
+        printIdentifier(getIndexName(index));
+        printEndOfStatement();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws IOException
+    {
+        String sourceNativeType = getBareNativeType(sourceColumn);
+        String targetNativeType = getBareNativeType(targetColumn);
+
+        if (sourceNativeType.equals(targetNativeType))
+        {
+            printIdentifier(getColumnName(sourceColumn));
+        }
+        else
+        {
+            // DB2 has the limitation that it cannot convert numeric values
+            // to VARCHAR, though it can convert them to CHAR
+            if (TypeMap.isNumericType(sourceColumn.getTypeCode()) &&
+                "VARCHAR".equalsIgnoreCase(targetNativeType))
+            {
+                targetNativeType = "CHAR";
+            }
+
+            print(targetNativeType);
+            print("(");
+            printIdentifier(getColumnName(sourceColumn));
+            print(")");
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void processTableStructureChanges(Database currentModel,
+                                                Database desiredModel,
+                                                Table    sourceTable,
+                                                Table    targetTable,
+                                                Map      parameters,
+                                                List     changes) throws IOException
+    {
+        // DB2 provides only limited ways to alter a column, so we don't use them
+        for (Iterator changeIt = changes.iterator(); changeIt.hasNext();)
+        {
+            TableChange change = (TableChange)changeIt.next();
+
+            if (change instanceof AddColumnChange)
+            {
+                AddColumnChange addColumnChange = (AddColumnChange)change;
+
+                // DB2 can only add not insert columns
+                if (addColumnChange.getNextColumn() == null)
+                {
+                    processChange(currentModel, desiredModel, addColumnChange);
+                    change.apply(currentModel);
+                    changeIt.remove();
+                }
+            }
+        }
+
+        for (Iterator changeIt = changes.iterator(); changeIt.hasNext();)
+        {
+            TableChange change = (TableChange)changeIt.next();
+
+            if (change instanceof AddPrimaryKeyChange)
+            {
+                processChange(currentModel, desiredModel, (AddPrimaryKeyChange)change);
+                change.apply(currentModel);
+                changeIt.remove();
+            }
+            else if (change instanceof PrimaryKeyChange)
+            {
+                processChange(currentModel, desiredModel, (PrimaryKeyChange)change);
+                change.apply(currentModel);
+                changeIt.remove();
+            }
+            else if (change instanceof RemovePrimaryKeyChange)
+            {
+                processChange(currentModel, desiredModel, (RemovePrimaryKeyChange)change);
+                change.apply(currentModel);
+                changeIt.remove();
+            }
+        }
+    }
+
+    /**
+     * Processes the addition of a column to 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,
+                                 AddColumnChange change) throws IOException
+    {
+        print("ALTER TABLE ");
+        printlnIdentifier(getTableName(change.getChangedTable()));
+        printIndent();
+        print("ADD COLUMN ");
+        writeColumn(change.getChangedTable(), change.getNewColumn());
+        printEndOfStatement();
+    }
+
+    /**
+     * Processes the removal of a column 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,
+                                 RemoveColumnChange change) throws IOException
+    {
+        print("ALTER TABLE ");
+        printlnIdentifier(getTableName(change.getChangedTable()));
+        printIndent();
+        print("DROP COLUMN ");
+        printIdentifier(getColumnName(change.getColumn()));
+        printEndOfStatement();
+    }
+
+    /**
+     * 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();
+    }
+
+    /**
+     * Processes the change of the primary key of 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,
+                                 PrimaryKeyChange change) throws IOException
+    {
+        print("ALTER TABLE ");
+        printlnIdentifier(getTableName(change.getChangedTable()));
+        printIndent();
+        print("DROP PRIMARY KEY");
+        printEndOfStatement();
+        writeExternalPrimaryKeysCreateStmt(change.getChangedTable(), change.getNewPrimaryKeyColumns());
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java Sat May
13 16:16:45 2006
@@ -16,8 +16,10 @@
  * limitations under the License.
  */
 
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Types;
+import java.util.HashSet;
 import java.util.Map;
 
 import org.apache.ddlutils.DdlUtilsException;
@@ -168,11 +170,12 @@
 	/**
      * {@inheritDoc}
      */
-    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+    protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
Index index) throws SQLException
     {
+        // Db2 uses the form "SQL060205225246220" if the primary key was defined during table
creation
+        // When the ALTER TABLE way was used however, the index has the name of the primary
key
     	if (index.getName().startsWith("SQL"))
     	{
-            // Db2 uses the form "SQL060205225246220"
     		try
     		{
     			Long.parseLong(index.getName().substring(3));
@@ -182,7 +185,34 @@
     		{
     			// we ignore it
     		}
+            return false;
     	}
-		return false;
+        else
+        {
+            // we'll compare the index name to the names of all primary keys
+            // TODO: Once primary key names are supported, this can be done easier via the
table object
+            ResultSet pkData  = null;
+            HashSet   pkNames = new HashSet();
+
+            try
+            {
+                pkData = metaData.getPrimaryKeys(table.getName());
+                while (pkData.next())
+                {
+                    Map values = readColumns(pkData, getColumnsForPK());
+
+                    pkNames.add(values.get("PK_NAME"));
+                }
+            }
+            finally
+            {
+                if (pkData != null)
+                {
+                    pkData.close();
+                }
+            }
+
+            return pkNames.contains(index.getName());
+        }
     }
 }

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=406163&r1=406162&r2=406163&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 16:16:45 2006
@@ -24,7 +24,6 @@
 
 import org.apache.ddlutils.Platform;
 import org.apache.ddlutils.alteration.AddColumnChange;
-import org.apache.ddlutils.alteration.ColumnSizeChange;
 import org.apache.ddlutils.alteration.TableChange;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Database;
@@ -160,28 +159,6 @@
         printIndent();
         print("ADD COLUMN ");
         writeColumn(change.getChangedTable(), change.getNewColumn());
-        printEndOfStatement();
-    }
-
-    /**
-     * Processes the size change of a VARCHAR column.
-     * 
-     * @param currentModel The current database schema
-     * @param desiredModel The desired database schema
-     * @param change       The change object
-     */
-    protected void processVarCharSizeChange(Database         currentModel,
-                                            Database         desiredModel,
-                                            ColumnSizeChange change) throws IOException
-    {
-        print("ALTER TABLE ");
-        printlnIdentifier(getTableName(change.getChangedTable()));
-        printIndent();
-        print("ALTER ");
-        printIdentifier(getColumnName(change.getChangedColumn()));
-        print(" SET DATA TYPE VARCHAR(");
-        print(change.getChangedColumn().getSize());
-        print(")");
         printEndOfStatement();
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyModelReader.java Sat
May 13 16:16:45 2006
@@ -70,7 +70,7 @@
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalForeignKeyIndex(Table table, ForeignKey fk, Index index)
+    protected boolean isInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
ForeignKey fk, Index index)
     {
         return isInternalIndex(index);
     }
@@ -78,7 +78,7 @@
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+    protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
Index index)
     {
         return isInternalIndex(index);
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java?rev=406163&r1=406162&r2=406163&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
Sat May 13 16:16:45 2006
@@ -328,7 +328,7 @@
     /**
 	 * {@inheritDoc}
 	 */
-	protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+	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");
@@ -337,7 +337,7 @@
 	/**
 	 * {@inheritDoc}
 	 */
-	protected boolean isInternalForeignKeyIndex(Table table, ForeignKey fk, Index index)
+	protected boolean isInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
ForeignKey fk, Index index)
 	{
 		// Firebird generates a normal index that has the same name as the fk
 		return fk.getName().equals(index.getName());

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbModelReader.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbModelReader.java
Sat May 13 16:16:45 2006
@@ -69,7 +69,7 @@
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalForeignKeyIndex(Table table, ForeignKey fk, Index index)
+    protected boolean isInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
ForeignKey fk, Index index)
     {
         String name = index.getName();
 
@@ -79,7 +79,7 @@
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+    protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
Index index)
     {
         String name = index.getName();
 

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java
Sat May 13 16:16:45 2006
@@ -168,7 +168,7 @@
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+    protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
Index index)
     {
         // Interbase generates an unique index for the pks of the form "RDB$PRIMARY825"
         return index.getName().startsWith("RDB$PRIMARY");

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java Sat
May 13 16:16:45 2006
@@ -22,7 +22,6 @@
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.sql.Types;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.ddlutils.DdlUtilsException;
@@ -124,7 +123,7 @@
     /**
      * {@inheritDoc}
      */
-	protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+	protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
Index index)
 	{
 		// Sql Server generates an index "PK__[table name]__[hex number]"
 		StringBuffer pkIndexName = new StringBuffer();
@@ -221,6 +220,4 @@
 
 		return column;
 	}
-
-
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySql50ModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySql50ModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySql50ModelReader.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySql50ModelReader.java
Sat May 13 16:16:45 2006
@@ -1,7 +1,7 @@
 package org.apache.ddlutils.platform.mysql;
 
 /*
- * Copyright 1999-2006 The Apache Software Foundation.
+ * Copyright 2005-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.
@@ -55,5 +55,4 @@
         }
         return column;
     }
-    
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelReader.java Sat
May 13 16:16:45 2006
@@ -86,7 +86,7 @@
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+    protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
Index index)
     {
         // MySql defines a unique index "PRIMARY" for primary keys
         return "PRIMARY".equals(index.getName());
@@ -95,7 +95,7 @@
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalForeignKeyIndex(Table table, ForeignKey fk, Index index)
+    protected boolean isInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
ForeignKey fk, Index index)
     {
         // MySql defines a non-unique index of the same name as the fk
         return getPlatform().getSqlBuilder().getForeignKeyName(table, fk).equals(index.getName());

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
Sat May 13 16:16:45 2006
@@ -199,7 +199,7 @@
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalForeignKeyIndex(Table table, ForeignKey fk, Index index)
+    protected boolean isInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
ForeignKey fk, Index index)
     {
         // PostgreSQL does not return an index for a foreign key
         return false;
@@ -208,7 +208,7 @@
     /**
      * {@inheritDoc}
      */
-    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+    protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
Index index)
     {
         // PostgreSql uses the form "[tablename]_pkey"
         return (table.getName() + "_pkey").equals(index.getName());

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
Sat May 13 16:16:45 2006
@@ -153,7 +153,7 @@
 	/**
      * {@inheritDoc}
      */
-    protected boolean isInternalPrimaryKeyIndex(Table table, Index index)
+    protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table,
Index index)
     {
         // Sybase defines a unique index "<table name>_<integer numer>" for primary
keys
     	if (index.isUnique() && (index.getName() != null))

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java?rev=406163&r1=406162&r2=406163&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java Sat May
13 16:16:45 2006
@@ -48,7 +48,7 @@
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='ddlutils'>\n"+
             "  <table name='TestTable'>\n"+
-            "    <column name='Id'   type='INTEGER' primaryKey='true'/>\n"+
+            "    <column name='Id' type='INTEGER' primaryKey='true' required='true'/>\n"+
             "    <column name='Text' type='VARCHAR' size='15'/>\n"+
             "  </table>\n"+
             "</database>");
@@ -106,7 +106,7 @@
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='ddlutils'>\n"+
             "  <table name='TestTable'>\n"+
-            "    <column name='Id'   type='INTEGER' primaryKey='true'/>\n"+
+            "    <column name='Id' type='INTEGER' primaryKey='true' required='true'/>\n"+
             "    <column name='Text' type='VARCHAR' size='15'/>\n"+
             "  </table>\n"+
             "</database>");
@@ -155,11 +155,11 @@
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='ddlutils'>\n"+
             "  <table name='TestTable1'>\n"+
-            "    <column name='Id1' type='INTEGER' primaryKey='true'/>\n"+
+            "    <column name='Id1' type='INTEGER' primaryKey='true' required='true'/>\n"+
             "    <column name='Id2' type='INTEGER'/>\n"+
             "  </table>\n"+
             "  <table name='TestTable2'>\n"+
-            "    <column name='Id' type='INTEGER' primaryKey='true'/>\n"+
+            "    <column name='Id' type='INTEGER' primaryKey='true' required='true'/>\n"+
             "    <column name='Avalue' type='VARCHAR' size='15'/>\n"+
             "  </table>\n"+
             "</database>");

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java?rev=406163&r1=406162&r2=406163&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 Sat May 13 16:16:45
2006
@@ -75,7 +75,9 @@
     }
 
     /**
-     * Tests the alteration of a column datatype.
+     * Tests the alteration of a column datatype. Note that this test is known to fail on
+     * Derby and DB2 as they have no way to convert a numeric value to a VARCHAR, only to
+     * CHAR which will pad the value with spaces.
      */
     public void testChangeDatatype2()
     {



Mime
View raw message