db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r710206 - in /db/ddlutils/trunk/src: main/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java test/java/org/apache/ddlutils/io/TestConstraints.java test/java/org/apache/ddlutils/platform/TestPostgresqlPlatform.java
Date Mon, 03 Nov 2008 22:48:36 GMT
Author: tomdz
Date: Mon Nov  3 14:48:36 2008
New Revision: 710206

URL: http://svn.apache.org/viewvc?rev=710206&view=rev
Log:
Fix for DDLUTILS-199: Postgress AutoIncrement fails

Modified:
    db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
    db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestConstraints.java
    db/ddlutils/trunk/src/test/java/org/apache/ddlutils/platform/TestPostgresqlPlatform.java

Modified: db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java?rev=710206&r1=710205&r2=710206&view=diff
==============================================================================
--- db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
(original)
+++ db/ddlutils/trunk/src/main/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
Mon Nov  3 14:48:36 2008
@@ -133,7 +133,13 @@
     protected void writeColumnAutoIncrementStmt(Table table, Column column) throws IOException
     {
         print("UNIQUE DEFAULT nextval('");
+        if (getPlatform().isDelimitedIdentifierModeOn()) {
+            print("\"");
+        }
         print(getConstraintName(null, table, column.getName(), "seq"));
+        if (getPlatform().isDelimitedIdentifierModeOn()) {
+            print("\"");
+        }
         print("')");
     }
 
@@ -160,7 +166,13 @@
                     result.append(", ");
                 }
                 result.append("currval('");
+                if (getPlatform().isDelimitedIdentifierModeOn()) {
+                    result.append("\"");
+                }
                 result.append(getConstraintName(null, table, columns[idx].getName(), "seq"));
+                if (getPlatform().isDelimitedIdentifierModeOn()) {
+                    result.append("\"");
+                }
                 result.append("') AS ");
                 result.append(getDelimitedIdentifier(columns[idx].getName()));
             }

Modified: db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestConstraints.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestConstraints.java?rev=710206&r1=710205&r2=710206&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestConstraints.java (original)
+++ db/ddlutils/trunk/src/test/java/org/apache/ddlutils/io/TestConstraints.java Mon Nov  3
14:48:36 2008
@@ -284,6 +284,37 @@
     }
 
     /**
+     * Test for DDLUTILS-199. 
+     */
+    public void testAutoIncrementPrimaryKeyWithUnderscoreInName()
+    {
+        // we need special catering for Sybase which does not support identity for INTEGER
columns
+        final String modelXml; 
+
+        if (SybasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            modelXml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                       "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
+                       "  <table name='roundtrip'>\n"+
+                       "    <column name='PK_Column' type='NUMERIC' size='12,0' primaryKey='true'
required='true' autoIncrement='true'/>\n"+
+                       "  </table>\n"+
+                       "</database>";
+        }
+        else
+        {
+            modelXml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                       "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='roundtriptest'>\n"+
+                       "  <table name='roundtrip'>\n"+
+                       "    <column name='PK_Column' type='INTEGER' primaryKey='true'
required='true' autoIncrement='true'/>\n"+
+                       "  </table>\n"+
+                       "</database>";
+        }
+
+        performConstraintsTest(modelXml,
+                               getPlatformInfo().getIdentityStatusReadingSupported());
+    }
+
+    /**
      * Tests a simple index. 
      */
     public void testIndex()

Modified: db/ddlutils/trunk/src/test/java/org/apache/ddlutils/platform/TestPostgresqlPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/java/org/apache/ddlutils/platform/TestPostgresqlPlatform.java?rev=710206&r1=710205&r2=710206&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/java/org/apache/ddlutils/platform/TestPostgresqlPlatform.java
(original)
+++ db/ddlutils/trunk/src/test/java/org/apache/ddlutils/platform/TestPostgresqlPlatform.java
Mon Nov  3 14:48:36 2008
@@ -96,11 +96,11 @@
             "CREATE TABLE \"constraints\"\n"+
             "(\n"+
             "    \"COL_PK\"               VARCHAR(32),\n"+
-            "    \"COL_PK_AUTO_INCR\"     INTEGER UNIQUE DEFAULT nextval('constraints_COL_K_AUTO_INCR_seq'),\n"+
+            "    \"COL_PK_AUTO_INCR\"     INTEGER UNIQUE DEFAULT nextval('\"constraints_COL_K_AUTO_INCR_seq\"'),\n"+
             "    \"COL_NOT_NULL\"         BYTEA NOT NULL,\n"+
             "    \"COL_NOT_NULL_DEFAULT\" DOUBLE PRECISION DEFAULT -2.0 NOT NULL,\n"+
             "    \"COL_DEFAULT\"          CHAR(4) DEFAULT 'test',\n"+
-            "    \"COL_AUTO_INCR\"        BIGINT UNIQUE DEFAULT nextval('constraints_COL_AUTO_INCR_seq'),\n"+
+            "    \"COL_AUTO_INCR\"        BIGINT UNIQUE DEFAULT nextval('\"constraints_COL_AUTO_INCR_seq\"'),\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
             getConstraintTestDatabaseCreationSql());



Mime
View raw message