db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r378736 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/platform/ java/org/apache/ddlutils/platform/axion/ java/org/apache/ddlutils/platform/cloudscape/ java/org/apache/ddlutils/platform/db2/ java/org/apache/ddlutils/platform/firebird...
Date Sat, 18 Feb 2006 16:08:48 GMT
Author: tomdz
Date: Sat Feb 18 08:08:45 2006
New Revision: 378736

URL: http://svn.apache.org/viewcvs?rev=378736&view=rev
Log:
Fixed test errors
Added character escaping for default values and creation of insert and update sql

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapeBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.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/oracle/Oracle8Platform.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/platform/TestAxionPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -26,6 +26,8 @@
 import java.util.Locale;
 import java.util.Map;
 
+import org.apache.commons.collections.map.ListOrderedMap;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ddlutils.DynaSqlException;
@@ -90,6 +92,9 @@
     /** Helper object for dealing with default values. */
     private DefaultValueHelper _defaultValueHelper = new DefaultValueHelper();
 
+    /** The character sequences that need escaping. */
+    private Map _charSequencesToEscape = new ListOrderedMap();
+
     //
     // Configuration
     //                
@@ -238,6 +243,17 @@
         _valueNumberFormat = null;
     }
 
+    /**
+     * Adds a char sequence that needs escaping, and its escaped version.
+     * 
+     * @param charSequence   The char sequence
+     * @param escapedVersion The escaped version
+     */
+    protected void addEscapedCharSequence(String charSequence, String escapedVersion)
+    {
+        _charSequencesToEscape.put(charSequence, escapedVersion);
+    }
+    
     //
     // public interface
     //
@@ -966,7 +982,7 @@
                 break;
             default:
                 result.append(getPlatformInfo().getValueQuoteToken());
-                result.append(value.toString());
+                result.append(escapeStringValue(value.toString()));
                 result.append(getPlatformInfo().getValueQuoteToken());
                 break;
         }
@@ -1246,6 +1262,25 @@
     {
         return column.getDefaultValue();
     }
+
+    /**
+     * Escapes the necessary characters in given string value.
+     * 
+     * @param value The value
+     * @return The corresponding string with the special characters properly escaped
+     */
+    protected String escapeStringValue(String value)
+    {
+        String result = value;
+
+        for (Iterator it = _charSequencesToEscape.entrySet().iterator(); it.hasNext();)
+        {
+            Map.Entry entry = (Map.Entry)it.next();
+
+            result = StringUtils.replace(result, (String)entry.getKey(), (String)entry.getValue());
+        }
+        return result;
+    }
     
     /**
      * Prints the default value of the column.
@@ -1259,12 +1294,14 @@
 
         if (shouldUseQuotes)
         {
+            // characters are only escaped when within a string literal 
+            print(getPlatformInfo().getValueQuoteToken());
+            print(escapeStringValue(getNativeDefaultValue(column).toString()));
             print(getPlatformInfo().getValueQuoteToken());
         }
-        print(getNativeDefaultValue(column).toString());
-        if (shouldUseQuotes)
+        else
         {
-            print(getPlatformInfo().getValueQuoteToken());
+            print(getNativeDefaultValue(column).toString());
         }
     }
 

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionBuilder.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionBuilder.java Sat Feb 18 08:08:45 2006
@@ -39,6 +39,7 @@
     public AxionBuilder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapeBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapeBuilder.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapeBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapeBuilder.java Sat Feb 18 08:08:45 2006
@@ -39,6 +39,7 @@
     public CloudscapeBuilder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
     }
 
     /**

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=378736&r1=378735&r2=378736&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 Feb 18 08:08:45 2006
@@ -42,8 +42,8 @@
     public Db2Builder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
     }
-
 
     /**
      * {@inheritDoc}

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -45,6 +45,7 @@
     public FirebirdBuilder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
     }
 
     /**
@@ -80,7 +81,7 @@
             println(", 1);");
             println("END;");
             print(TERM_COMMAND);
-            print(";");
+            printEndOfStatement();
         }
     }
 

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -39,6 +39,7 @@
     public HsqlDbBuilder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java Sat Feb 18 08:08:45 2006
@@ -22,7 +22,6 @@
 import org.apache.ddlutils.DynaSqlException;
 import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.platform.PlatformImplBase;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * The platform implementation for the HsqlDb database.
@@ -65,12 +64,10 @@
         info.addNativeTypeMapping(Types.STRUCT,      "LONGVARBINARY", Types.LONGVARBINARY);
         // JDBC's TINYINT requires a value range of -255 to 255, but HsqlDb's is only -128 to 127
         info.addNativeTypeMapping(Types.TINYINT,     "SMALLINT",      Types.SMALLINT);
-        if (Jdbc3Utils.supportsJava14JdbcTypes())
-        {
-            // when using JDBC3, BIT will be back-mapped to BOOLEAN
-            info.addNativeTypeMapping("BIT", "BOOLEAN", "BOOLEAN");
-            info.addNativeTypeMapping("DATALINK", "LONGVARBINARY");
-        }
+
+        // when using JDBC3, BIT will be back-mapped to BOOLEAN
+        info.addNativeTypeMapping("BIT",      "BOOLEAN",       "BOOLEAN");
+        info.addNativeTypeMapping("DATALINK", "LONGVARBINARY", "LONGVARBINARY");
 
         info.addDefaultSize(Types.CHAR,      Integer.MAX_VALUE);
         info.addDefaultSize(Types.VARCHAR,   Integer.MAX_VALUE);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java Sat Feb 18 08:08:45 2006
@@ -42,6 +42,7 @@
     public InterbaseBuilder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.java Sat Feb 18 08:08:45 2006
@@ -40,6 +40,10 @@
     public MckoiBuilder(PlatformInfo info)
     {
         super(info);
+        // we need to handle the backslash first otherwise the other
+        // already escaped sequence would be affected
+        addEscapedCharSequence("\\", "\\\\");
+        addEscapedCharSequence("'",  "\\'");
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -48,6 +48,7 @@
     public MSSqlBuilder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -44,6 +44,19 @@
     public MySqlBuilder(PlatformInfo info)
     {
         super(info);
+        // we need to handle the backslash first otherwise the other
+        // already escaped sequences would be affected
+        addEscapedCharSequence("\\",     "\\\\");
+        addEscapedCharSequence("\0",     "\\0");
+        addEscapedCharSequence("'",      "\\'");
+        addEscapedCharSequence("\"",     "\\\"");
+        addEscapedCharSequence("\b",     "\\b");
+        addEscapedCharSequence("\n",     "\\n");
+        addEscapedCharSequence("\r",     "\\r");
+        addEscapedCharSequence("\t",     "\\t");
+        addEscapedCharSequence("\u001A", "\\Z");
+        addEscapedCharSequence("%",      "\\%");
+        addEscapedCharSequence("_",      "\\_");
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -58,6 +58,7 @@
     public Oracle8Builder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
 
         PatternCompiler compiler = new Perl5Compiler();
 
@@ -149,11 +150,12 @@
         if (shouldUseQuotes)
         {
             print(getPlatformInfo().getValueQuoteToken());
+            print(escapeStringValue(nativeDefault));
+            print(getPlatformInfo().getValueQuoteToken());
         }
-        print(getNativeDefaultValue(column).toString());
-        if (shouldUseQuotes)
+        else
         {
-            print(getPlatformInfo().getValueQuoteToken());
+            print(nativeDefault);
         }
 	}
 

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java Sat Feb 18 08:08:45 2006
@@ -87,8 +87,8 @@
         info.addNativeTypeMapping(Types.VARBINARY,     "RAW");
         info.addNativeTypeMapping(Types.VARCHAR,       "VARCHAR2");
 
-        info.addNativeTypeMapping("BOOLEAN",  "NUMBER(1,0)", "BIT");
-        info.addNativeTypeMapping("DATALINK", "BLOB",        "BLOB");
+        info.addNativeTypeMapping("BOOLEAN",  "NUMBER(1)", "BIT");
+        info.addNativeTypeMapping("DATALINK", "BLOB",      "BLOB");
 
         info.addDefaultSize(Types.CHAR,       254);
         info.addDefaultSize(Types.VARCHAR,    254);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -42,6 +42,15 @@
     public PostgreSqlBuilder(PlatformInfo info)
     {
         super(info);
+        // we need to handle the backslash first otherwise the other
+        // already escaped sequences would be affected
+        addEscapedCharSequence("\\", "\\\\");
+        addEscapedCharSequence("'",  "\\'");
+        addEscapedCharSequence("\b", "\\b");
+        addEscapedCharSequence("\f", "\\f");
+        addEscapedCharSequence("\n", "\\n");
+        addEscapedCharSequence("\r", "\\r");
+        addEscapedCharSequence("\t", "\\t");
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -40,6 +40,7 @@
     public SapDbBuilder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -42,6 +42,7 @@
     public SybaseBuilder(PlatformInfo info)
     {
         super(info);
+        addEscapedCharSequence("'", "''");
     }
 
     /**

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestAxionPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestAxionPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestAxionPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestAxionPlatform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestAxionPlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -137,5 +147,21 @@
             "ALTER TABLE table2 ADD CONSTRAINT table2_FK_COL_FK_1_COL_FK_2_table1 FOREIGN KEY (COL_FK_1, COL_FK_2) REFERENCES table1 (COL_PK_2, COL_PK_1);\n"+
             "ALTER TABLE table3 ADD CONSTRAINT testfk FOREIGN KEY (COL_FK) REFERENCES table2 (COL_PK);\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Axion requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE IF EXISTS escapedcharacters;\n"+
+            "CREATE TABLE escapedcharacters\n"+
+            "(\n"+
+            "    COL_PK   INTEGER,\n"+
+            "    COL_TEXT VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (COL_PK)\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestCloudscapePlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -137,5 +147,21 @@
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Cloudscape requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\";\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestDB2Platform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -58,13 +68,13 @@
             "    \"COL_DECIM_NOSCALE\" DECIMAL(15,0),\n"+       // only 18 characters allowed for identifiers
             "    \"COL_DISTINCT\"      DISTINCT,\n"+
             "    \"COL_DOUBLE\"        DOUBLE,\n"+
-            "    \"COL_FLOAT\"         REAL,\n"+
+            "    \"COL_FLOAT\"         DOUBLE,\n"+
             "    \"COL_INTEGER\"       INTEGER,\n"+
             "    \"COL_JAVA_OBJECT\"   BLOB,\n"+
             "    \"COL_LONGVARBINARY\" LONG VARCHAR FOR BIT DATA,\n"+
             "    \"COL_LONGVARCHAR\"   LONG VARCHAR,\n"+
             "    \"COL_NULL\"          LONG VARCHAR FOR BIT DATA,\n"+
-            "    \"COL_NUMERIC\"       NUMERIC(15,0),\n"+
+            "    \"COL_NUMERIC\"       DECIMAL(15,0),\n"+
             "    \"COL_OTHER\"         BLOB,\n"+
             "    \"COL_REAL\"          REAL,\n"+
             "    \"COL_REF\"           REF,\n"+
@@ -139,5 +149,21 @@
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Db2 requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\";\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestDerbyPlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -137,5 +147,21 @@
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Derby requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\";\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java?rev=378736&r1=378735&r2=378736&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 Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestFirebirdPlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -42,15 +52,14 @@
     {
         assertEqualsIgnoringWhitespaces(
             "DROP TABLE \"coltype\";\n"+
-            "COMMIT;\n"+
             "CREATE TABLE \"coltype\"\n"+
             "(\n"+
             "    \"COL_ARRAY\"           BLOB ,\n"+
-            "    \"COL_BIGINT\"          DECIMAL(38,0),\n"+
-            "    \"COL_BINARY\"          CHAR CHARACTER SET OCTETS,\n"+
-            "    \"COL_BIT\"             DECIMAL(1,0),\n"+
+            "    \"COL_BIGINT\"          BIGINT,\n"+
+            "    \"COL_BINARY\"          BLOB,\n"+
+            "    \"COL_BIT\"             SMALLINT,\n"+
             "    \"COL_BLOB\"            BLOB ,\n"+
-            "    \"COL_BOOLEAN\"         DECIMAL(1,0),\n"+
+            "    \"COL_BOOLEAN\"         SMALLINT,\n"+
             "    \"COL_CHAR\"            CHAR(15),\n"+
             "    \"COL_CLOB\"            BLOB SUB_TYPE TEXT,\n"+
             "    \"COL_DATALINK\"        BLOB,\n"+
@@ -74,10 +83,9 @@
             "    \"COL_TIME\"            TIME,\n"+
             "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
             "    \"COL_TINYINT\"         SMALLINT,\n"+
-            "    \"COL_VARBINARY\"       VARCHAR(15) CHARACTER SET OCTETS,\n"+
+            "    \"COL_VARBINARY\"       BLOB(15),\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
-            ");\n"+
-            "COMMIT;\n",
+            ");\n",
             createTestDatabase(COLUMN_TEST_SCHEMA));
     }
 
@@ -87,45 +95,37 @@
     public void testColumnConstraints() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DELETE FROM RDB$GENERATOR WHERE RDB$GENERATOR_NAME = \"gen_constraints_OL_PK_AUTO_INCR\";\n" +
-            "COMMIT;\n"+
-            "DELETE FROM RDB$GENERATOR WHERE RDB$GENERATOR_NAME = \"gen_constraints_COL_AUTO_INCR\";\n" +
-            "COMMIT;\n"+
             "DROP TABLE \"constraints\";\n"+
-            "COMMIT;\n"+
+            "DROP GENERATOR \"gen_constraints_OL_PK_AUTO_INCR\";\n" +
+            "DROP GENERATOR \"gen_constraints_COL_AUTO_INCR\";\n" +
             "CREATE TABLE \"constraints\"\n"+
             "(\n"+
             "    \"COL_PK\"               VARCHAR(32),\n"+
             "    \"COL_PK_AUTO_INCR\"     INTEGER,\n"+
-            "    \"COL_NOT_NULL\"         CHAR(100) CHARACTER SET OCTETS NOT NULL,\n"+
+            "    \"COL_NOT_NULL\"         BLOB(100) 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\"        DECIMAL(38,0),\n"+
+            "    \"COL_AUTO_INCR\"        BIGINT,\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n"+
-            "COMMIT;\n"+
             "CREATE GENERATOR \"gen_constraints_OL_PK_AUTO_INCR\";\n" +
-            "COMMIT;\n"+
-            "SET TERM !! ;\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"+
-            "SET TERM ; !!\n"+
-            "COMMIT;\n"+
+            "END;\n"+
+            "--TERM--;\n"+
             "CREATE GENERATOR \"gen_constraints_COL_AUTO_INCR\";\n" +
-            "COMMIT;\n"+
-            "SET TERM !! ;\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"+
-            "SET TERM ; !!\n"+
-            "COMMIT;\n",
+            "END;\n"+
+            "--TERM--;\n",
             createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
     }
 
@@ -136,27 +136,21 @@
     {
         assertEqualsIgnoringWhitespaces(
             "ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+
-            "COMMIT;\n"+
             "ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_COL_F_COL_FK_2_table1\";\n"+
-            "COMMIT;\n"+
             "DROP TABLE \"table3\";\n"+
-            "COMMIT;\n"+
             "DROP TABLE \"table2\";\n"+
-            "COMMIT;\n"+
             "DROP TABLE \"table1\";\n"+
-            "COMMIT;\n"+
             "CREATE TABLE \"table1\"\n"+
             "(\n"+
             "    \"COL_PK_1\"    VARCHAR(32) NOT NULL,\n"+
             "    \"COL_PK_2\"    INTEGER,\n"+
-            "    \"COL_INDEX_1\" CHAR(100) CHARACTER SET OCTETS NOT NULL,\n"+
+            "    \"COL_INDEX_1\" BLOB(100) NOT NULL,\n"+
             "    \"COL_INDEX_2\" DOUBLE PRECISION NOT NULL,\n"+
             "    \"COL_INDEX_3\" CHAR(4),\n"+
             "    PRIMARY KEY (\"COL_PK_1\", \"COL_PK_2\")\n"+
             ");\n"+
             "CREATE INDEX \"testindex1\" ON \"table1\" (\"COL_INDEX_2\");\n"+
             "CREATE UNIQUE INDEX \"testindex2\" ON \"table1\" (\"COL_INDEX_3\", \"COL_INDEX_1\");\n"+
-            "COMMIT;\n"+
             "CREATE TABLE \"table2\"\n"+
             "(\n"+
             "    \"COL_PK\"   INTEGER,\n"+
@@ -164,18 +158,30 @@
             "    \"COL_FK_2\" VARCHAR(32) NOT NULL,\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n"+
-            "COMMIT;\n"+
             "CREATE TABLE \"table3\"\n"+
             "(\n"+
             "    \"COL_PK\" VARCHAR(16),\n"+
             "    \"COL_FK\" INTEGER NOT NULL,\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n"+
-            "COMMIT;\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
-            "COMMIT;\n"+
-            "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n"+
-            "COMMIT;\n",
+            "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Firebird requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\";\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java Sat Feb 18 08:08:45 2006
@@ -28,6 +28,28 @@
  */
 public class TestHsqlDbPlatform extends TestPlatformBase
 {
+    /** The database schema for testing column constraints. This is an version adapted for HsqlDb. */
+    public static final String COLUMN_CONSTRAINT_TEST_SCHEMA =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='columnconstraintstest'>\n" +
+        "  <table name='constraints'>\n" +
+        "    <column name='COL_PK' type='VARCHAR' size='32' primaryKey='true'/>\n" +
+        "    <column name='COL_PK_AUTO_INCR' type='INTEGER' primaryKey='true' autoIncrement='true'/>\n" +
+        "    <column name='COL_NOT_NULL' type='BINARY' size='100' required='true'/>\n" +
+        "    <column name='COL_NOT_NULL_DEFAULT' type='DOUBLE' required='true' default='-2.0'/>\n" +
+        "    <column name='COL_DEFAULT' type='CHAR' size='4' default='test'/>\n" +
+        "  </table>\n" +
+        "</database>";
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -47,10 +69,10 @@
             "(\n" + //
             "    \"COL_ARRAY\"           LONGVARBINARY,\n"+
             "    \"COL_BIGINT\"          BIGINT,\n"+
-            "    \"COL_BINARY\"          BINARY,\n"+
-            "    \"COL_BIT\"             BIT,\n"+
+            "    \"COL_BINARY\"          BINARY("+Integer.MAX_VALUE+"),\n"+
+            "    \"COL_BIT\"             BOOLEAN,\n"+
             "    \"COL_BLOB\"            LONGVARBINARY,\n"+
-            "    \"COL_BOOLEAN\"         BIT,\n"+
+            "    \"COL_BOOLEAN\"         BOOLEAN,\n"+
             "    \"COL_CHAR\"            CHAR(15),\n"+
             "    \"COL_CLOB\"            LONGVARCHAR,\n"+
             "    \"COL_DATALINK\"        LONGVARBINARY,\n"+
@@ -73,7 +95,7 @@
             "    \"COL_STRUCT\"          LONGVARBINARY,\n"+
             "    \"COL_TIME\"            TIME,\n"+
             "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
-            "    \"COL_TINYINT\"         TINYINT,\n"+
+            "    \"COL_TINYINT\"         SMALLINT,\n"+
             "    \"COL_VARBINARY\"       VARBINARY(15),\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
@@ -85,8 +107,6 @@
      */
     public void testColumnConstraints() throws Exception
     {
-        // Note that this is not valid in Hsqldb as it supports only one IDENTITY column per table
-        // and a IDENTITY column also needs to be a primary key column (which COL_AUTO_INCR isn't)
         assertEqualsIgnoringWhitespaces(
             "DROP TABLE \"constraints\" IF EXISTS;\n" +
             "CREATE TABLE \"constraints\"\n"+
@@ -96,7 +116,6 @@
             "    \"COL_NOT_NULL\"         BINARY(100) NOT NULL,\n"+
             "    \"COL_NOT_NULL_DEFAULT\" DOUBLE DEFAULT -2.0 NOT NULL,\n"+
             "    \"COL_DEFAULT\"          CHAR(4) DEFAULT 'test',\n"+
-            "    \"COL_AUTO_INCR\"        BIGINT IDENTITY,\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
             createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
@@ -140,5 +159,21 @@
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where HsqlDb requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\" IF EXISTS;\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestInterbasePlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -177,5 +187,23 @@
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n"+
             "COMMIT;\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Firebird requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\";\n"+
+            "COMMIT;\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "COMMIT;\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestMSSqlPlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -72,7 +82,7 @@
             "(\n"+
             "    \"COL_ARRAY\"           IMAGE,\n"+
             "    \"COL_BIGINT\"          DECIMAL(19,0),\n"+
-            "    \"COL_BINARY\"          BINARY,\n"+
+            "    \"COL_BINARY\"          BINARY(254),\n"+
             "    \"COL_BIT\"             BIT,\n"+
             "    \"COL_BLOB\"            IMAGE,\n"+
             "    \"COL_BOOLEAN\"         BIT,\n"+
@@ -271,5 +281,47 @@
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Cloudscape requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "SET quoted_identifier on;\n"+
+            "SET quoted_identifier on;\n"+
+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'escapedcharacters')\n"+
+            "BEGIN\n"+
+            "     DECLARE @reftable nvarchar(60), @constraintname nvarchar(60)\n"+
+            "     DECLARE refcursor CURSOR FOR\n"+
+            "     select reftables.name tablename, cons.name constraintname\n"+
+            "      from sysobjects tables,\n"+
+            "           sysobjects reftables,\n"+
+            "           sysobjects cons,\n"+
+            "           sysreferences ref\n"+
+            "       where tables.id = ref.rkeyid\n"+
+            "         and cons.id = ref.constid\n"+
+            "         and reftables.id = ref.fkeyid\n"+
+            "         and tables.name = 'escapedcharacters'\n"+
+            "     OPEN refcursor\n"+
+            "     FETCH NEXT from refcursor into @reftable, @constraintname\n"+
+            "     while @@FETCH_STATUS = 0\n"+
+            "     BEGIN\n"+
+            "       exec ('alter table '+@reftable+' drop constraint '+@constraintname)\n"+
+            "       FETCH NEXT from refcursor into @reftable, @constraintname\n"+
+            "     END\n"+
+            "     CLOSE refcursor\n"+
+            "     DEALLOCATE refcursor\n"+
+            "     DROP TABLE \"escapedcharacters\"\n"+
+            "END;\n"+
+            "SET quoted_identifier on;\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INT,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java Sat Feb 18 08:08:45 2006
@@ -138,4 +138,20 @@
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
     }
+
+    /**
+     * Tests the proper escaping of character sequences where MaxDb requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\" CASCADE;\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(TestSapDbPlatform.COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+    }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,52 @@
  */
 public class TestMcKoiPlatform extends TestPlatformBase
 {
+    /** The database schema for testing table constraints, ie. foreign keys and indices.
+        This schema is adapted for McKoi which does not support non-unique indices. */
+    public static final String TABLE_CONSTRAINT_TEST_SCHEMA =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='tableconstraintstest'>\n" +
+        "  <table name='table1'>\n" +
+        "    <column name='COL_PK_1' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n" +
+        "    <column name='COL_PK_2' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_INDEX_1' type='BINARY' size='100' required='true'/>\n" +
+        "    <column name='COL_INDEX_2' type='DOUBLE' required='true'/>\n" +
+        "    <column name='COL_INDEX_3' type='CHAR' size='4'/>\n" +
+        "    <unique name='testindex1'>\n" +
+        "      <unique-column name='COL_INDEX_2'/>\n" +
+        "    </unique>\n" +
+        "    <unique name='testindex2'>\n" +
+        "      <unique-column name='COL_INDEX_3'/>\n" +
+        "      <unique-column name='COL_INDEX_1'/>\n" +
+        "    </unique>\n" +
+        "  </table>\n" +
+        "  <table name='table2'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_FK_1' type='INTEGER'/>\n" +
+        "    <column name='COL_FK_2' type='VARCHAR' size='32' required='true'/>\n" +
+        "    <foreign-key foreignTable='table1'>\n" +
+        "      <reference local='COL_FK_1' foreign='COL_PK_2'/>\n" +
+        "      <reference local='COL_FK_2' foreign='COL_PK_1'/>\n" +
+        "    </foreign-key>\n" +
+        "  </table>\n" +
+        "  <table name='table3'>\n" +
+        "    <column name='COL_PK' type='VARCHAR' size='16' primaryKey='true'/>\n" +
+        "    <column name='COL_FK' type='INTEGER' required='true'/>\n" +
+        "    <foreign-key name='testfk' foreignTable='table2'>\n" +
+        "      <reference local='COL_FK' foreign='COL_PK'/>\n" +
+        "    </foreign-key>\n" +
+        "  </table>\n" +
+        "</database>";
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39; \\'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -46,7 +92,7 @@
             "(\n"+
             "    \"COL_ARRAY\"           BLOB,\n"+
             "    \"COL_BIGINT\"          BIGINT,\n"+
-            "    \"COL_BINARY\"          BINARY,\n"+
+            "    \"COL_BINARY\"          BINARY(1024),\n"+
             "    \"COL_BIT\"             BOOLEAN,\n"+
             "    \"COL_BLOB\"            BLOB,\n"+
             "    \"COL_BOOLEAN\"         BOOLEAN,\n"+
@@ -91,11 +137,11 @@
             "CREATE TABLE \"constraints\"\n"+
             "(\n"+
             "    \"COL_PK\"               VARCHAR(32),\n"+
-            "    \"COL_PK_AUTO_INCR\"     INTEGER DEFAULT UNIQUEKEY(\"constraints\") + 1,\n"+
+            "    \"COL_PK_AUTO_INCR\"     INTEGER DEFAULT UNIQUEKEY('constraints') + 1,\n"+
             "    \"COL_NOT_NULL\"         BINARY(100) NOT NULL,\n"+
             "    \"COL_NOT_NULL_DEFAULT\" DOUBLE DEFAULT -2.0 NOT NULL,\n"+
             "    \"COL_DEFAULT\"          CHAR(4) DEFAULT 'test',\n"+
-            "    \"COL_AUTO_INCR\"        BIGINT DEFAULT UNIQUEKEY(\"constraints\") + 1,\n"+
+            "    \"COL_AUTO_INCR\"        BIGINT DEFAULT UNIQUEKEY('constraints') + 1,\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
             createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
@@ -119,10 +165,10 @@
             "    \"COL_INDEX_1\" BINARY(100) NOT NULL,\n"+
             "    \"COL_INDEX_2\" DOUBLE NOT NULL,\n"+
             "    \"COL_INDEX_3\" CHAR(4),\n"+
-            "    PRIMARY KEY (\"COL_PK_1\", \"COL_PK_2\")\n"+
+            "    PRIMARY KEY (\"COL_PK_1\", \"COL_PK_2\"),\n"+
+            "    CONSTRAINT \"testindex1\" UNIQUE (\"COL_INDEX_2\"),\n"+
+            "    CONSTRAINT \"testindex2\" UNIQUE (\"COL_INDEX_3\", \"COL_INDEX_1\")\n"+
             ");\n"+
-            "CREATE INDEX \"testindex1\" ON \"table1\" (\"COL_INDEX_2\");\n"+
-            "CREATE UNIQUE INDEX \"testindex2\" ON \"table1\" (\"COL_INDEX_3\", \"COL_INDEX_1\");\n"+
             "CREATE TABLE \"table2\"\n"+
             "(\n"+
             "    \"COL_PK\"   INTEGER,\n"+
@@ -139,5 +185,21 @@
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where McKoi requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE IF EXISTS \"escapedcharacters\";\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\\\' \\\\',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java Sat Feb 18 08:08:45 2006
@@ -181,4 +181,20 @@
             ") ENGINE=INNODB ROW_FORMAT=COMPRESSED;\n",
             getBuilderOutput());
     }
+
+    /**
+     * Tests the proper escaping of character sequences where MySQL requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE IF EXISTS `escapedcharacters`;\n"+
+            "CREATE TABLE `escapedcharacters`\n"+
+            "(\n"+
+            "    `COL_PK`   INTEGER,\n"+
+            "    `COL_TEXT` VARCHAR(128) DEFAULT '\\_ \\\' \\\" \\n \\r \\t \\\\ \\%' NULL,\n"+
+            "    PRIMARY KEY (`COL_PK`)\n"+
+            ");\n",
+            createTestDatabase(TestMySqlPlatform.COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+    }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java Sat Feb 18 08:08:45 2006
@@ -28,6 +28,16 @@
  */
 public class TestMySqlPlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='_ &#39; \" &#10; &#13; &#09; \\ &#37;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -85,7 +95,8 @@
      */
     public void testColumnConstraints() throws Exception
     {
-        Database           testDb = parseDatabaseFromString(COLUMN_CONSTRAINT_TEST_SCHEMA);
+        Database testDb = parseDatabaseFromString(COLUMN_CONSTRAINT_TEST_SCHEMA);
+
         testDb.findTable("constraints").findColumn("COL_AUTO_INCR").setAutoIncrement(false);
         testDb.findTable("constraints").findColumn("COL_PK_AUTO_INCR").setAutoIncrement(false);
 
@@ -152,9 +163,11 @@
      */
     public void testCreationParameters1() throws Exception
     {
-        Database           testDb = parseDatabaseFromString(COLUMN_CONSTRAINT_TEST_SCHEMA);
+        Database testDb = parseDatabaseFromString(COLUMN_CONSTRAINT_TEST_SCHEMA);
+
         testDb.findTable("constraints").findColumn("COL_AUTO_INCR").setAutoIncrement(false);
         testDb.findTable("constraints").findColumn("COL_PK_AUTO_INCR").setAutoIncrement(false);
+
         CreationParameters params = new CreationParameters();
 
         params.addParameter(testDb.getTable(0),
@@ -180,5 +193,21 @@
             "    PRIMARY KEY (`COL_PK`, `COL_PK_AUTO_INCR`)\n"+
             ") ENGINE=INNODB ROW_FORMAT=COMPRESSED;\n",
             getBuilderOutput());
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where MySQL requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE IF EXISTS `escapedcharacters`;\n"+
+            "CREATE TABLE `escapedcharacters`\n"+
+            "(\n"+
+            "    `COL_PK`   INTEGER,\n"+
+            "    `COL_TEXT` VARCHAR(128) DEFAULT '\\_ \\\' \\\" \\n \\r \\t \\\\ \\%' NULL,\n"+
+            "    PRIMARY KEY (`COL_PK`)\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestOracle8Platform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -45,11 +55,11 @@
             "CREATE TABLE \"coltype\"\n"+
             "(\n"+
             "    \"COL_ARRAY\"           BLOB,\n"+
-            "    \"COL_BIGINT\"          NUMBER(38,0),\n"+
+            "    \"COL_BIGINT\"          NUMBER(38),\n"+
             "    \"COL_BINARY\"          RAW(254),\n"+
-            "    \"COL_BIT\"             NUMBER(1,0),\n"+
+            "    \"COL_BIT\"             NUMBER(1),\n"+
             "    \"COL_BLOB\"            BLOB,\n"+
-            "    \"COL_BOOLEAN\"         NUMBER(1,0),\n"+
+            "    \"COL_BOOLEAN\"         NUMBER(1),\n"+
             "    \"COL_CHAR\"            CHAR(15),\n"+
             "    \"COL_CLOB\"            CLOB,\n"+
             "    \"COL_DATALINK\"        BLOB,\n"+
@@ -57,22 +67,22 @@
             "    \"COL_DECIMAL\"         NUMBER(15,3),\n"+
             "    \"COL_DECIMAL_NOSCALE\" NUMBER(15,0),\n"+
             "    \"COL_DISTINCT\"        BLOB,\n"+
-            "    \"COL_DOUBLE\"          NUMBER(38),\n"+
-            "    \"COL_FLOAT\"           NUMBER(38),\n"+
-            "    \"COL_INTEGER\"         NUMBER(20,0),\n"+
+            "    \"COL_DOUBLE\"          DOUBLE PRECISION,\n"+
+            "    \"COL_FLOAT\"           FLOAT,\n"+
+            "    \"COL_INTEGER\"         INTEGER,\n"+
             "    \"COL_JAVA_OBJECT\"     BLOB,\n"+
             "    \"COL_LONGVARBINARY\"   BLOB,\n"+
             "    \"COL_LONGVARCHAR\"     CLOB,\n"+
             "    \"COL_NULL\"            BLOB,\n"+
             "    \"COL_NUMERIC\"         NUMBER(15,0),\n"+
             "    \"COL_OTHER\"           BLOB,\n"+
-            "    \"COL_REAL\"            NUMBER(18),\n"+
+            "    \"COL_REAL\"            REAL,\n"+
             "    \"COL_REF\"             BLOB,\n"+
-            "    \"COL_SMALLINT\"        NUMBER(5,0),\n"+
+            "    \"COL_SMALLINT\"        NUMBER(5),\n"+
             "    \"COL_STRUCT\"          BLOB,\n"+
             "    \"COL_TIME\"            DATE,\n"+
             "    \"COL_TIMESTAMP\"       DATE,\n"+
-            "    \"COL_TINYINT\"         NUMBER(3,0),\n"+
+            "    \"COL_TINYINT\"         NUMBER(3),\n"+
             "    \"COL_VARBINARY\"       RAW(15),\n"+
             "    \"COL_VARCHAR\"         VARCHAR2(15)\n"+
             ");\n",
@@ -95,21 +105,19 @@
             "CREATE TABLE \"constraints\"\n"+
             "(\n"+
             "    \"COL_PK\"               VARCHAR2(32),\n"+
-            "    \"COL_PK_AUTO_INCR\"     NUMBER(20,0),\n"+
+            "    \"COL_PK_AUTO_INCR\"     INTEGER,\n"+
             "    \"COL_NOT_NULL\"         RAW(100) NOT NULL,\n"+
-            "    \"COL_NOT_NULL_DEFAULT\" NUMBER(38) DEFAULT -2.0 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\"        NUMBER(38,0),\n"+
+            "    \"COL_AUTO_INCR\"        NUMBER(38),\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n"+
             "CREATE OR REPLACE TRIGGER \"trg_constraints_L_PK_AUTO_INCR\" BEFORE INSERT ON \"constraints\" FOR EACH ROW\n"+
             "BEGIN\n"+
             "  SELECT \"seq_constraints_L_PK_AUTO_INCR\".nextval INTO :new.\"COL_PK_AUTO_INCR\" FROM dual;\n"+
-            "END;\n"+
             "CREATE OR REPLACE TRIGGER \"trg_constraints_COL_AUTO_INCR\" BEFORE INSERT ON \"constraints\" FOR EACH ROW\n"+
             "BEGIN\n"+
-            "  SELECT \"seq_constraints_COL_AUTO_INCR\".nextval INTO :new.\"COL_AUTO_INCR\" FROM dual;\n"+
-            "END;\n",
+            "  SELECT \"seq_constraints_COL_AUTO_INCR\".nextval INTO :new.\"COL_AUTO_INCR\" FROM dual;\n",
             createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
     }
 
@@ -125,9 +133,9 @@
             "CREATE TABLE \"table1\"\n"+
             "(\n"+
             "    \"COL_PK_1\"    VARCHAR2(32) NOT NULL,\n"+
-            "    \"COL_PK_2\"    NUMBER(20,0),\n"+
+            "    \"COL_PK_2\"    INTEGER,\n"+
             "    \"COL_INDEX_1\" RAW(100) NOT NULL,\n"+
-            "    \"COL_INDEX_2\" NUMBER(38) NOT NULL,\n"+
+            "    \"COL_INDEX_2\" DOUBLE PRECISION NOT NULL,\n"+
             "    \"COL_INDEX_3\" CHAR(4),\n"+
             "    PRIMARY KEY (\"COL_PK_1\", \"COL_PK_2\")\n"+
             ");\n"+
@@ -135,19 +143,35 @@
             "CREATE UNIQUE INDEX \"testindex2\" ON \"table1\" (\"COL_INDEX_3\", \"COL_INDEX_1\");\n"+
             "CREATE TABLE \"table2\"\n"+
             "(\n"+
-            "    \"COL_PK\"   NUMBER(20,0),\n"+
-            "    \"COL_FK_1\" NUMBER(20,0),\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_FK_1\" INTEGER,\n"+
             "    \"COL_FK_2\" VARCHAR2(32) NOT NULL,\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n"+
             "CREATE TABLE \"table3\"\n"+
             "(\n"+
             "    \"COL_PK\" VARCHAR2(16),\n"+
-            "    \"COL_FK\" NUMBER(20,0) NOT NULL,\n"+
+            "    \"COL_FK\" INTEGER NOT NULL,\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_OL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Oracle requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\" CASCADE CONSTRAINTS;\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR2(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java Sat Feb 18 08:08:45 2006
@@ -45,11 +45,11 @@
             "CREATE TABLE \"coltype\"\n"+
             "(\n"+
             "    \"COL_ARRAY\"           BLOB,\n"+
-            "    \"COL_BIGINT\"          NUMBER(38,0),\n"+
+            "    \"COL_BIGINT\"          NUMBER(38),\n"+
             "    \"COL_BINARY\"          RAW(254),\n"+
-            "    \"COL_BIT\"             NUMBER(1,0),\n"+
+            "    \"COL_BIT\"             NUMBER(1),\n"+
             "    \"COL_BLOB\"            BLOB,\n"+
-            "    \"COL_BOOLEAN\"         NUMBER(1,0),\n"+
+            "    \"COL_BOOLEAN\"         NUMBER(1),\n"+
             "    \"COL_CHAR\"            CHAR(15),\n"+
             "    \"COL_CLOB\"            CLOB,\n"+
             "    \"COL_DATALINK\"        BLOB,\n"+
@@ -57,22 +57,22 @@
             "    \"COL_DECIMAL\"         NUMBER(15,3),\n"+
             "    \"COL_DECIMAL_NOSCALE\" NUMBER(15,0),\n"+
             "    \"COL_DISTINCT\"        BLOB,\n"+
-            "    \"COL_DOUBLE\"          NUMBER(38),\n"+
-            "    \"COL_FLOAT\"           NUMBER(38),\n"+
-            "    \"COL_INTEGER\"         NUMBER(20,0),\n"+
+            "    \"COL_DOUBLE\"          DOUBLE PRECISION,\n"+
+            "    \"COL_FLOAT\"           FLOAT,\n"+
+            "    \"COL_INTEGER\"         INTEGER,\n"+
             "    \"COL_JAVA_OBJECT\"     BLOB,\n"+
             "    \"COL_LONGVARBINARY\"   BLOB,\n"+
             "    \"COL_LONGVARCHAR\"     CLOB,\n"+
             "    \"COL_NULL\"            BLOB,\n"+
             "    \"COL_NUMERIC\"         NUMBER(15,0),\n"+
             "    \"COL_OTHER\"           BLOB,\n"+
-            "    \"COL_REAL\"            NUMBER(18),\n"+
+            "    \"COL_REAL\"            REAL,\n"+
             "    \"COL_REF\"             BLOB,\n"+
-            "    \"COL_SMALLINT\"        NUMBER(5,0),\n"+
+            "    \"COL_SMALLINT\"        NUMBER(5),\n"+
             "    \"COL_STRUCT\"          BLOB,\n"+
             "    \"COL_TIME\"            DATE,\n"+
             "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
-            "    \"COL_TINYINT\"         NUMBER(3,0),\n"+
+            "    \"COL_TINYINT\"         NUMBER(3),\n"+
             "    \"COL_VARBINARY\"       RAW(15),\n"+
             "    \"COL_VARCHAR\"         VARCHAR2(15)\n"+
             ");\n",
@@ -95,21 +95,19 @@
             "CREATE TABLE \"constraints\"\n"+
             "(\n"+
             "    \"COL_PK\"               VARCHAR2(32),\n"+
-            "    \"COL_PK_AUTO_INCR\"     NUMBER(20,0),\n"+
+            "    \"COL_PK_AUTO_INCR\"     INTEGER,\n"+
             "    \"COL_NOT_NULL\"         RAW(100) NOT NULL,\n"+
-            "    \"COL_NOT_NULL_DEFAULT\" NUMBER(38) DEFAULT -2.0 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\"        NUMBER(38,0),\n"+
+            "    \"COL_AUTO_INCR\"        NUMBER(38),\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n"+
             "CREATE OR REPLACE TRIGGER \"trg_constraints_L_PK_AUTO_INCR\" BEFORE INSERT ON \"constraints\" FOR EACH ROW\n"+
             "BEGIN\n"+
             "  SELECT \"seq_constraints_L_PK_AUTO_INCR\".nextval INTO :new.\"COL_PK_AUTO_INCR\" FROM dual;\n"+
-            "END;\n"+
             "CREATE OR REPLACE TRIGGER \"trg_constraints_COL_AUTO_INCR\" BEFORE INSERT ON \"constraints\" FOR EACH ROW\n"+
             "BEGIN\n"+
-            "  SELECT \"seq_constraints_COL_AUTO_INCR\".nextval INTO :new.\"COL_AUTO_INCR\" FROM dual;\n"+
-            "END;\n",
+            "  SELECT \"seq_constraints_COL_AUTO_INCR\".nextval INTO :new.\"COL_AUTO_INCR\" FROM dual;\n",
             createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
     }
 
@@ -125,9 +123,9 @@
             "CREATE TABLE \"table1\"\n"+
             "(\n"+
             "    \"COL_PK_1\"    VARCHAR2(32) NOT NULL,\n"+
-            "    \"COL_PK_2\"    NUMBER(20,0),\n"+
+            "    \"COL_PK_2\"    INTEGER,\n"+
             "    \"COL_INDEX_1\" RAW(100) NOT NULL,\n"+
-            "    \"COL_INDEX_2\" NUMBER(38) NOT NULL,\n"+
+            "    \"COL_INDEX_2\" DOUBLE PRECISION NOT NULL,\n"+
             "    \"COL_INDEX_3\" CHAR(4),\n"+
             "    PRIMARY KEY (\"COL_PK_1\", \"COL_PK_2\")\n"+
             ");\n"+
@@ -135,19 +133,35 @@
             "CREATE UNIQUE INDEX \"testindex2\" ON \"table1\" (\"COL_INDEX_3\", \"COL_INDEX_1\");\n"+
             "CREATE TABLE \"table2\"\n"+
             "(\n"+
-            "    \"COL_PK\"   NUMBER(20,0),\n"+
-            "    \"COL_FK_1\" NUMBER(20,0),\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_FK_1\" INTEGER,\n"+
             "    \"COL_FK_2\" VARCHAR2(32) NOT NULL,\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n"+
             "CREATE TABLE \"table3\"\n"+
             "(\n"+
             "    \"COL_PK\" VARCHAR2(16),\n"+
-            "    \"COL_FK\" NUMBER(20,0) NOT NULL,\n"+
+            "    \"COL_FK\" INTEGER NOT NULL,\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_OL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Oracle requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\" CASCADE CONSTRAINTS;\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR2(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(TestOracle8Platform.COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestPostgresqlPlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39; &#09; &#10; &#13; \\'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -141,5 +151,21 @@
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where PostgreSQL requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\" CASCADE;\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\\\' \\t \\n \\r \\\\',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestSapDbPlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -137,5 +147,21 @@
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Cloudscape requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"escapedcharacters\" CASCADE;\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java?rev=378736&r1=378735&r2=378736&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java Sat Feb 18 08:08:45 2006
@@ -27,6 +27,16 @@
  */
 public class TestSybasePlatform extends TestPlatformBase
 {
+    /** The database schema for testing escaping of character sequences. */
+    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
+        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+        "<database name='escapetest'>\n" +
+        "  <table name='escapedcharacters'>\n" +
+        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+        "  </table>\n" +
+        "</database>";
+
     /**
      * {@inheritDoc}
      */
@@ -170,5 +180,27 @@
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_OL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
             createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the proper escaping of character sequences where Cloudscape requires it.
+     */
+    public void testCharacterEscaping() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "SET quoted_identifier on;\n"+
+            "SET quoted_identifier on;\n"+
+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'escapedcharacters')\n"+
+            "BEGIN\n"+
+            "    DROP TABLE \"escapedcharacters\"\n"+
+            "END;\n"+
+            "SET quoted_identifier on;\n"+
+            "CREATE TABLE \"escapedcharacters\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INT,\n"+
+            "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
     }
 }



Mime
View raw message