db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r481167 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/platform/SqlBuilder.java test/org/apache/ddlutils/io/TestAlteration.java
Date Fri, 01 Dec 2006 06:27:08 GMT
Author: tomdz
Date: Thu Nov 30 22:27:08 2006
New Revision: 481167

URL: http://svn.apache.org/viewvc?view=rev&rev=481167
Log:
Fix and test for DDLUTILS-126

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

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java?view=diff&rev=481167&r1=481166&r2=481167
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java Thu Nov 30 22:27:08
2006
@@ -668,19 +668,7 @@
                                  CreationParameters params,
                                  AddTableChange     change) throws IOException
     {
-        // TODO: where to get the parameters from ?
-        writeTableCreationStmt(desiredModel, change.getNewTable(), null);
-        writeTableCreationStmtEnding(change.getNewTable(), null);
-
-        if (!getPlatformInfo().isPrimaryKeyEmbedded())
-        {
-            writeExternalPrimaryKeysCreateStmt(change.getNewTable(),
-                                               change.getNewTable().getPrimaryKeyColumns());
-        }
-        if (!getPlatformInfo().isIndicesEmbedded())
-        {
-            writeExternalIndicesCreateStmt(change.getNewTable());
-        }
+        createTable(desiredModel, change.getNewTable(), params == null ? null : params.getParametersFor(change.getNewTable()));
     }
 
     /**

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?view=diff&rev=481167&r1=481166&r2=481167
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java Thu Nov 30 22:27:08
2006
@@ -1661,6 +1661,43 @@
     }
 
     /**
+     * Tests the addition of a table with an auto-increment primary key.
+     */
+    public void testAddAutoIncrementTable()
+    {
+        final String model1Xml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='VARCHAR' size='20' 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='roundtrip1'>\n"+
+            "    <column name='pk' type='VARCHAR' size='20' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' autoIncrement='true'
required='true'/>\n"+
+            "  </table>\n"+
+           "</database>";
+
+        createDatabase(model1Xml);
+
+        insertRow("roundtrip1", new Object[] { new Integer(1) });
+
+        alterDatabase(model2Xml);
+
+        assertEquals(getAdjustedModel(),
+                     readModelFromDatabase("roundtriptest"));
+
+        List beans = getRows("roundtrip1");
+
+        assertEquals((Object)"1", beans.get(0), "pk");
+    }
+
+    /**
      * Tests the removal of a table.
      */
     public void testRemoveTable1()



Mime
View raw message