db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r518498 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform: SqlBuilder.java mysql/MySqlBuilder.java
Date Thu, 15 Mar 2007 06:57:13 GMT
Author: tomdz
Date: Wed Mar 14 23:57:13 2007
New Revision: 518498

URL: http://svn.apache.org/viewvc?view=rev&rev=518498
Log:
Final fix for DDLUTILS-159

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java

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?view=diff&rev=518498&r1=518497&r2=518498
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java Wed Mar 14 23:57:13
2007
@@ -911,7 +911,30 @@
         Table sourceTable = currentModel.findTable(tableName, getPlatform().isDelimitedIdentifierModeOn());
         Table targetTable = desiredModel.findTable(tableName, getPlatform().isDelimitedIdentifierModeOn());
 
-        processTableStructureChanges(currentModel, desiredModel, sourceTable, targetTable,
parameters, changes);
+        // we're enforcing a full rebuild in case of the addition of a required
+        // column without a default value that is not autoincrement
+        boolean requiresFullRebuild = false;
+
+        for (Iterator changeIt = changes.iterator(); !requiresFullRebuild && changeIt.hasNext();)
+        {
+            TableChange change = (TableChange)changeIt.next();
+
+            if (change instanceof AddColumnChange)
+            {
+                AddColumnChange addColumnChange = (AddColumnChange)change;
+
+                if (addColumnChange.getNewColumn().isRequired() &&
+                    (addColumnChange.getNewColumn().getDefaultValue() == null) &&
+                    !addColumnChange.getNewColumn().isAutoIncrement())
+                {
+                    requiresFullRebuild = true;
+                }
+            }
+        }
+        if (!requiresFullRebuild)
+        {
+            processTableStructureChanges(currentModel, desiredModel, sourceTable, targetTable,
parameters, changes);
+        }
 
         if (!changes.isEmpty())
         {

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?view=diff&rev=518498&r1=518497&r2=518498
==============================================================================
--- 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 Wed Mar
14 23:57:13 2007
@@ -183,17 +183,7 @@
 
             if (change instanceof AddColumnChange)
             {
-                AddColumnChange addColumnChange = (AddColumnChange)change;
-
-                if (addColumnChange.getNewColumn().isRequired() &&
-                    (addColumnChange.getNewColumn().getDefaultValue() == null) &&
-                    !addColumnChange.getNewColumn().isAutoIncrement())
-                {
-                    // we're enforcing a full rebuild in case of the addition of a required
-                    // column without a default value that is not autoincrement
-                    return;
-                }
-                addColumnChanges.add(change);
+                addColumnChanges.add((AddColumnChange)change);
                 changeIt.remove();
             }
         }



Mime
View raw message