db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r289996 [2/3] - in /db/ddlutils/trunk: ./ src/java/org/apache/ddlutils/ src/java/org/apache/ddlutils/builder/ src/java/org/apache/ddlutils/model/ src/java/org/apache/ddlutils/platform/ src/test/org/apache/ddlutils/ src/test/org/apache/ddlut...
Date Sun, 18 Sep 2005 23:01:23 GMT
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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -41,41 +41,101 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE coltype;\n"+
-            "CREATE TABLE coltype\n"+
+            "DROP TABLE \"coltype\";\n"+
+            "CREATE TABLE \"coltype\"\n"+
             "(\n"+
-            "    COL_ARRAY           BLOB,\n"+
-            "    COL_BIGINT          BIGINT,\n"+
-            "    COL_BINARY          CHAR(254) FOR BIT DATA,\n"+
-            "    COL_BIT             CHAR FOR BIT DATA,\n"+
-            "    COL_BLOB            BLOB,\n"+
-            "    COL_BOOLEAN         CHAR FOR BIT DATA,\n"+
-            "    COL_CHAR            CHAR(15),\n"+
-            "    COL_CLOB            CLOB,\n"+
-            "    COL_DATALINK        LONG VARCHAR FOR BIT DATA,\n"+
-            "    COL_DATE            DATE,\n"+
-            "    COL_DECIMAL         DECIMAL(15,3),\n"+
-            "    COL_DECIMAL_NOSCALE DECIMAL(15,0),\n"+
-            "    COL_DISTINCT        BLOB,\n"+
-            "    COL_DOUBLE          DOUBLE PRECISION,\n"+
-            "    COL_FLOAT           DOUBLE PRECISION,\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_OTHER           BLOB,\n"+
-            "    COL_REAL            REAL,\n"+
-            "    COL_REF             LONG VARCHAR FOR BIT DATA,\n"+
-            "    COL_SMALLINT        SMALLINT,\n"+
-            "    COL_STRUCT          BLOB,\n"+
-            "    COL_TIME            TIME,\n"+
-            "    COL_TIMESTAMP       TIMESTAMP,\n"+
-            "    COL_TINYINT         SMALLINT,\n"+
-            "    COL_VARBINARY       VARCHAR(15) FOR BIT DATA,\n"+
-            "    COL_VARCHAR         VARCHAR(15)\n"+
+            "    \"COL_ARRAY\"           BLOB,\n"+
+            "    \"COL_BIGINT\"          BIGINT,\n"+
+            "    \"COL_BINARY\"          CHAR(254) FOR BIT DATA,\n"+
+            "    \"COL_BIT\"             CHAR FOR BIT DATA,\n"+
+            "    \"COL_BLOB\"            BLOB,\n"+
+            "    \"COL_BOOLEAN\"         CHAR FOR BIT DATA,\n"+
+            "    \"COL_CHAR\"            CHAR(15),\n"+
+            "    \"COL_CLOB\"            CLOB,\n"+
+            "    \"COL_DATALINK\"        LONG VARCHAR FOR BIT DATA,\n"+
+            "    \"COL_DATE\"            DATE,\n"+
+            "    \"COL_DECIMAL\"         DECIMAL(15,3),\n"+
+            "    \"COL_DECIMAL_NOSCALE\" DECIMAL(15,0),\n"+
+            "    \"COL_DISTINCT\"        BLOB,\n"+
+            "    \"COL_DOUBLE\"          DOUBLE PRECISION,\n"+
+            "    \"COL_FLOAT\"           DOUBLE PRECISION,\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_OTHER\"           BLOB,\n"+
+            "    \"COL_REAL\"            REAL,\n"+
+            "    \"COL_REF\"             LONG VARCHAR FOR BIT DATA,\n"+
+            "    \"COL_SMALLINT\"        SMALLINT,\n"+
+            "    \"COL_STRUCT\"          BLOB,\n"+
+            "    \"COL_TIME\"            TIME,\n"+
+            "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
+            "    \"COL_TINYINT\"         SMALLINT,\n"+
+            "    \"COL_VARBINARY\"       VARCHAR(15) FOR BIT DATA,\n"+
+            "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the column constraints.
+     */
+    public void testColumnConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"constraints\";\n" +
+            "CREATE TABLE \"constraints\"\n"+
+            "(\n"+
+            "    \"COL_PK\"               VARCHAR(32),\n"+
+            "    \"COL_PK_AUTO_INCR\"     INTEGER GENERATED ALWAYS AS IDENTITY,\n"+
+            "    \"COL_NOT_NULL\"         CHAR(100) FOR BIT DATA 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 GENERATED ALWAYS AS IDENTITY,\n"+
+            "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+
+            "ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\";\n"+
+            "DROP TABLE \"table3\";\n"+
+            "DROP TABLE \"table2\";\n"+
+            "DROP TABLE \"table1\";\n"+
+            "CREATE TABLE \"table1\"\n"+
+            "(\n"+
+            "    \"COL_PK_1\"    VARCHAR(32) NOT NULL,\n"+
+            "    \"COL_PK_2\"    INTEGER,\n"+
+            "    \"COL_INDEX_1\" CHAR(100) FOR BIT DATA 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"+
+            "CREATE TABLE \"table2\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_FK_1\" INTEGER,\n"+
+            "    \"COL_FK_2\" VARCHAR(32) NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "CREATE TABLE \"table3\"\n"+
+            "(\n"+
+            "    \"COL_PK\" VARCHAR(16),\n"+
+            "    \"COL_FK\" INTEGER NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "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));
     }
 }

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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -41,42 +41,103 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE coltype;\n"+
-            "DROP SEQUENCE IF EXISTS coltype.SequenceName;\n"+
-            "CREATE TABLE coltype\n"+
+            "DROP TABLE \"coltype\";\n"+
+            "CREATE TABLE \"coltype\"\n"+
             "(\n"+
-            "    COL_ARRAY         BLOB,\n"+
-            "    COL_BIGINT        BIGINT,\n"+
-            "    COL_BINARY        CHAR(254) FOR BIT DATA,\n"+
-            "    COL_BIT           CHAR FOR BIT DATA,\n"+
-            "    COL_BLOB          BLOB,\n"+
-            "    COL_BOOLEAN       CHAR FOR BIT DATA,\n"+
-            "    COL_CHAR          CHAR(15),\n"+
-            "    COL_CLOB          CLOB,\n"+
-            "    COL_DATALINK      DATALINK,\n"+
-            "    COL_DATE          DATE,\n"+
-            "    COL_DECIMAL       DECIMAL(15,3),\n"+
-            "    COL_DECIM_NOSCALE DECIMAL(15,0),\n"+       // only 18 characters allowed for identifiers
-            "    COL_DISTINCT      DISTINCT,\n"+
-            "    COL_DOUBLE        DOUBLE,\n"+
-            "    COL_FLOAT         FLOAT,\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_OTHER         BLOB,\n"+
-            "    COL_REAL          REAL,\n"+
-            "    COL_REF           REF,\n"+
-            "    COL_SMALLINT      SMALLINT,\n"+
-            "    COL_STRUCT        BLOB,\n"+
-            "    COL_TIME          TIME,\n"+
-            "    COL_TIMESTAMP     TIMESTAMP,\n"+
-            "    COL_TINYINT       SMALLINT,\n"+
-            "    COL_VARBINARY     VARCHAR(15) FOR BIT DATA,\n"+
-            "    COL_VARCHAR       VARCHAR(15)\n"+
+            "    \"COL_ARRAY\"         BLOB,\n"+
+            "    \"COL_BIGINT\"        BIGINT,\n"+
+            "    \"COL_BINARY\"        CHAR(254) FOR BIT DATA,\n"+
+            "    \"COL_BIT\"           CHAR FOR BIT DATA,\n"+
+            "    \"COL_BLOB\"          BLOB,\n"+
+            "    \"COL_BOOLEAN\"       CHAR FOR BIT DATA,\n"+
+            "    \"COL_CHAR\"          CHAR(15),\n"+
+            "    \"COL_CLOB\"          CLOB,\n"+
+            "    \"COL_DATALINK\"      DATALINK,\n"+
+            "    \"COL_DATE\"          DATE,\n"+
+            "    \"COL_DECIMAL\"       DECIMAL(15,3),\n"+
+            "    \"COL_DECIM_NOSCALE\" DECIMAL(15,0),\n"+       // only 18 characters allowed for identifiers
+            "    \"COL_DISTINCT\"      DISTINCT,\n"+
+            "    \"COL_DOUBLE\"        DOUBLE,\n"+
+            "    \"COL_FLOAT\"         FLOAT,\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_OTHER\"         BLOB,\n"+
+            "    \"COL_REAL\"          REAL,\n"+
+            "    \"COL_REF\"           REF,\n"+
+            "    \"COL_SMALLINT\"      SMALLINT,\n"+
+            "    \"COL_STRUCT\"        BLOB,\n"+
+            "    \"COL_TIME\"          TIME,\n"+
+            "    \"COL_TIMESTAMP\"     TIMESTAMP,\n"+
+            "    \"COL_TINYINT\"       SMALLINT,\n"+
+            "    \"COL_VARBINARY\"     VARCHAR(15) FOR BIT DATA,\n"+
+            "    \"COL_VARCHAR\"       VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+
+    /**
+     * Tests the column constraints.
+     */
+    public void testColumnConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"constraints\";\n" +
+            "CREATE TABLE \"constraints\"\n"+
+            "(\n"+
+            "    \"COL_PK\"            VARCHAR(32),\n"+
+            "    \"COL_PK_AUTO_INCR\"  INTEGER GENERATED BY DEFAULT AS IDENTITY,\n"+
+            "    \"COL_NOT_NULL\"      CHAR(100) FOR BIT DATA NOT NULL,\n"+
+            "    \"COL_NOT_N_DEFAULT\" DOUBLE DEFAULT '-2.0' NOT NULL,\n"+   // only 18 characters allowed for identifiers
+            "    \"COL_DEFAULT\"       CHAR(4) DEFAULT 'test',\n"+
+            "    \"COL_AUTO_INCR\"     BIGINT GENERATED BY DEFAULT AS IDENTITY,\n"+
+            "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+
+            "ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_2_table1\";\n"+
+            "DROP TABLE \"table3\";\n"+
+            "DROP TABLE \"table2\";\n"+
+            "DROP TABLE \"table1\";\n"+
+            "CREATE TABLE \"table1\"\n"+
+            "(\n"+
+            "    \"COL_PK_1\"    VARCHAR(32) NOT NULL,\n"+
+            "    \"COL_PK_2\"    INTEGER,\n"+
+            "    \"COL_INDEX_1\" CHAR(100) FOR BIT DATA 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"+
+            ");\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"+
+            "    \"COL_FK_1\" INTEGER,\n"+
+            "    \"COL_FK_2\" VARCHAR(32) NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "CREATE TABLE \"table3\"\n"+
+            "(\n"+
+            "    \"COL_PK\" VARCHAR(16),\n"+
+            "    \"COL_FK\" INTEGER NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "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));
     }
 }

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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -41,41 +41,101 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE coltype;\n"+
-            "CREATE TABLE coltype\n"+
+            "DROP TABLE \"coltype\";\n"+
+            "CREATE TABLE \"coltype\"\n"+
             "(\n"+
-            "    COL_ARRAY           BLOB,\n"+
-            "    COL_BIGINT          BIGINT,\n"+
-            "    COL_BINARY          CHAR(254) FOR BIT DATA,\n"+
-            "    COL_BIT             CHAR FOR BIT DATA,\n"+
-            "    COL_BLOB            BLOB,\n"+
-            "    COL_BOOLEAN         CHAR FOR BIT DATA,\n"+
-            "    COL_CHAR            CHAR(15),\n"+
-            "    COL_CLOB            CLOB,\n"+
-            "    COL_DATALINK        LONG VARCHAR FOR BIT DATA,\n"+
-            "    COL_DATE            DATE,\n"+
-            "    COL_DECIMAL         DECIMAL(15,3),\n"+
-            "    COL_DECIMAL_NOSCALE DECIMAL(15,0),\n"+
-            "    COL_DISTINCT        BLOB,\n"+
-            "    COL_DOUBLE          DOUBLE PRECISION,\n"+
-            "    COL_FLOAT           DOUBLE PRECISION,\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_OTHER           BLOB,\n"+
-            "    COL_REAL            REAL,\n"+
-            "    COL_REF             LONG VARCHAR FOR BIT DATA,\n"+
-            "    COL_SMALLINT        SMALLINT,\n"+
-            "    COL_STRUCT          BLOB,\n"+
-            "    COL_TIME            TIME,\n"+
-            "    COL_TIMESTAMP       TIMESTAMP,\n"+
-            "    COL_TINYINT         SMALLINT,\n"+
-            "    COL_VARBINARY       VARCHAR(15) FOR BIT DATA,\n"+
-            "    COL_VARCHAR         VARCHAR(15)\n"+
+            "    \"COL_ARRAY\"           BLOB,\n"+
+            "    \"COL_BIGINT\"          BIGINT,\n"+
+            "    \"COL_BINARY\"          CHAR(254) FOR BIT DATA,\n"+
+            "    \"COL_BIT\"             CHAR FOR BIT DATA,\n"+
+            "    \"COL_BLOB\"            BLOB,\n"+
+            "    \"COL_BOOLEAN\"         CHAR FOR BIT DATA,\n"+
+            "    \"COL_CHAR\"            CHAR(15),\n"+
+            "    \"COL_CLOB\"            CLOB,\n"+
+            "    \"COL_DATALINK\"        LONG VARCHAR FOR BIT DATA,\n"+
+            "    \"COL_DATE\"            DATE,\n"+
+            "    \"COL_DECIMAL\"         DECIMAL(15,3),\n"+
+            "    \"COL_DECIMAL_NOSCALE\" DECIMAL(15,0),\n"+
+            "    \"COL_DISTINCT\"        BLOB,\n"+
+            "    \"COL_DOUBLE\"          DOUBLE PRECISION,\n"+
+            "    \"COL_FLOAT\"           DOUBLE PRECISION,\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_OTHER\"           BLOB,\n"+
+            "    \"COL_REAL\"            REAL,\n"+
+            "    \"COL_REF\"             LONG VARCHAR FOR BIT DATA,\n"+
+            "    \"COL_SMALLINT\"        SMALLINT,\n"+
+            "    \"COL_STRUCT\"          BLOB,\n"+
+            "    \"COL_TIME\"            TIME,\n"+
+            "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
+            "    \"COL_TINYINT\"         SMALLINT,\n"+
+            "    \"COL_VARBINARY\"       VARCHAR(15) FOR BIT DATA,\n"+
+            "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the column constraints.
+     */
+    public void testColumnConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"constraints\";\n" +
+            "CREATE TABLE \"constraints\"\n"+
+            "(\n"+
+            "    \"COL_PK\"               VARCHAR(32),\n"+
+            "    \"COL_PK_AUTO_INCR\"     INTEGER GENERATED BY DEFAULT AS IDENTITY,\n"+
+            "    \"COL_NOT_NULL\"         CHAR(100) FOR BIT DATA 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 GENERATED BY DEFAULT AS IDENTITY,\n"+
+            "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+
+            "ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\";\n"+
+            "DROP TABLE \"table3\";\n"+
+            "DROP TABLE \"table2\";\n"+
+            "DROP TABLE \"table1\";\n"+
+            "CREATE TABLE \"table1\"\n"+
+            "(\n"+
+            "    \"COL_PK_1\"    VARCHAR(32) NOT NULL,\n"+
+            "    \"COL_PK_2\"    INTEGER,\n"+
+            "    \"COL_INDEX_1\" CHAR(100) FOR BIT DATA 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"+
+            "CREATE TABLE \"table2\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_FK_1\" INTEGER,\n"+
+            "    \"COL_FK_2\" VARCHAR(32) NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "CREATE TABLE \"table3\"\n"+
+            "(\n"+
+            "    \"COL_PK\" VARCHAR(16),\n"+
+            "    \"COL_FK\" INTEGER NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "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));
     }
 }

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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -41,43 +41,141 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE coltype;\n"+
+            "DROP TABLE \"coltype\";\n"+
             "COMMIT;\n"+
-            "CREATE TABLE coltype\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_BLOB            BLOB ,\n"+
-            "    COL_BOOLEAN         DECIMAL(1,0),\n"+
-            "    COL_CHAR            CHAR(15),\n"+
-            "    COL_CLOB            BLOB SUB_TYPE TEXT,\n"+
-            "    COL_DATALINK        BLOB,\n"+
-            "    COL_DATE            DATE,\n"+
-            "    COL_DECIMAL         DECIMAL(15,3),\n"+
-            "    COL_DECIMAL_NOSCALE DECIMAL(15,0),\n"+
-            "    COL_DISTINCT        BLOB,\n"+
-            "    COL_DOUBLE          DOUBLE PRECISION,\n"+
-            "    COL_FLOAT           DOUBLE PRECISION,\n"+
-            "    COL_INTEGER         INTEGER,\n"+
-            "    COL_JAVA_OBJECT     BLOB,\n"+
-            "    COL_LONGVARBINARY   BLOB,\n"+
-            "    COL_LONGVARCHAR     BLOB SUB_TYPE TEXT,\n"+
-            "    COL_NULL            BLOB,\n"+
-            "    COL_NUMERIC         NUMERIC(15,0),\n"+
-            "    COL_OTHER           BLOB,\n"+
-            "    COL_REAL            FLOAT,\n"+
-            "    COL_REF             BLOB,\n"+
-            "    COL_SMALLINT        SMALLINT,\n"+
-            "    COL_STRUCT          BLOB,\n"+
-            "    COL_TIME            TIME,\n"+
-            "    COL_TIMESTAMP       TIMESTAMP,\n"+
-            "    COL_TINYINT         SMALLINT,\n"+
-            "    COL_VARBINARY       VARCHAR(15) CHARACTER SET OCTETS,\n"+
-            "    COL_VARCHAR         VARCHAR(15)\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_BLOB\"            BLOB ,\n"+
+            "    \"COL_BOOLEAN\"         DECIMAL(1,0),\n"+
+            "    \"COL_CHAR\"            CHAR(15),\n"+
+            "    \"COL_CLOB\"            BLOB SUB_TYPE TEXT,\n"+
+            "    \"COL_DATALINK\"        BLOB,\n"+
+            "    \"COL_DATE\"            DATE,\n"+
+            "    \"COL_DECIMAL\"         DECIMAL(15,3),\n"+
+            "    \"COL_DECIMAL_NOSCALE\" DECIMAL(15,0),\n"+
+            "    \"COL_DISTINCT\"        BLOB,\n"+
+            "    \"COL_DOUBLE\"          DOUBLE PRECISION,\n"+
+            "    \"COL_FLOAT\"           DOUBLE PRECISION,\n"+
+            "    \"COL_INTEGER\"         INTEGER,\n"+
+            "    \"COL_JAVA_OBJECT\"     BLOB,\n"+
+            "    \"COL_LONGVARBINARY\"   BLOB,\n"+
+            "    \"COL_LONGVARCHAR\"     BLOB SUB_TYPE TEXT,\n"+
+            "    \"COL_NULL\"            BLOB,\n"+
+            "    \"COL_NUMERIC\"         NUMERIC(15,0),\n"+
+            "    \"COL_OTHER\"           BLOB,\n"+
+            "    \"COL_REAL\"            FLOAT,\n"+
+            "    \"COL_REF\"             BLOB,\n"+
+            "    \"COL_SMALLINT\"        SMALLINT,\n"+
+            "    \"COL_STRUCT\"          BLOB,\n"+
+            "    \"COL_TIME\"            TIME,\n"+
+            "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
+            "    \"COL_TINYINT\"         SMALLINT,\n"+
+            "    \"COL_VARBINARY\"       VARCHAR(15) CHARACTER SET OCTETS,\n"+
+            "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n"+
             "COMMIT;\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the column constraints.
+     */
+    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"+
+            "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_DEFAULT\" DOUBLE PRECISION DEFAULT '-2.0' NOT NULL,\n"+
+            "    \"COL_DEFAULT\"          CHAR(4) DEFAULT 'test',\n"+
+            "    \"COL_AUTO_INCR\"        DECIMAL(38,0),\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"+
+            "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"+
+            "CREATE GENERATOR \"gen_constraints_COL_AUTO_INCR\";\n" +
+            "COMMIT;\n"+
+            "SET 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",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        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_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"+
+            "    \"COL_FK_1\" INTEGER,\n"+
+            "    \"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",
+            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
     }
 }

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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -43,41 +43,103 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE coltype IF EXISTS;\n" + //
-            "CREATE TABLE coltype\n" + //
+            "DROP TABLE \"coltype\" IF EXISTS;\n" + //
+            "CREATE TABLE \"coltype\"\n" + //
             "(\n" + //
-            "    COL_ARRAY           LONGVARBINARY,\n"+
-            "    COL_BIGINT          BIGINT,\n"+
-            "    COL_BINARY          BINARY,\n"+
-            "    COL_BIT             BIT,\n"+
-            "    COL_BLOB            LONGVARBINARY,\n"+
-            "    COL_BOOLEAN         BIT,\n"+
-            "    COL_CHAR            CHAR(15),\n"+
-            "    COL_CLOB            LONGVARCHAR,\n"+
-            "    COL_DATALINK        LONGVARBINARY,\n"+
-            "    COL_DATE            DATE,\n"+
-            "    COL_DECIMAL         DECIMAL(15,3),\n"+
-            "    COL_DECIMAL_NOSCALE DECIMAL(15,0),\n"+
-            "    COL_DISTINCT        LONGVARBINARY,\n"+
-            "    COL_DOUBLE          DOUBLE,\n"+
-            "    COL_FLOAT           DOUBLE,\n"+
-            "    COL_INTEGER         INTEGER,\n"+
-            "    COL_JAVA_OBJECT     OBJECT,\n"+
-            "    COL_LONGVARBINARY   LONGVARBINARY,\n"+
-            "    COL_LONGVARCHAR     LONGVARCHAR,\n"+
-            "    COL_NULL            LONGVARBINARY,\n"+
-            "    COL_NUMERIC         NUMERIC(15,0),\n"+
-            "    COL_OTHER           OTHER,\n"+
-            "    COL_REAL            REAL,\n"+
-            "    COL_REF             LONGVARBINARY,\n"+
-            "    COL_SMALLINT        SMALLINT,\n"+
-            "    COL_STRUCT          LONGVARBINARY,\n"+
-            "    COL_TIME            TIME,\n"+
-            "    COL_TIMESTAMP       TIMESTAMP,\n"+
-            "    COL_TINYINT         TINYINT,\n"+
-            "    COL_VARBINARY       VARBINARY(15),\n"+
-            "    COL_VARCHAR         VARCHAR(15)\n"+
+            "    \"COL_ARRAY\"           LONGVARBINARY,\n"+
+            "    \"COL_BIGINT\"          BIGINT,\n"+
+            "    \"COL_BINARY\"          BINARY,\n"+
+            "    \"COL_BIT\"             BIT,\n"+
+            "    \"COL_BLOB\"            LONGVARBINARY,\n"+
+            "    \"COL_BOOLEAN\"         BIT,\n"+
+            "    \"COL_CHAR\"            CHAR(15),\n"+
+            "    \"COL_CLOB\"            LONGVARCHAR,\n"+
+            "    \"COL_DATALINK\"        LONGVARBINARY,\n"+
+            "    \"COL_DATE\"            DATE,\n"+
+            "    \"COL_DECIMAL\"         DECIMAL(15,3),\n"+
+            "    \"COL_DECIMAL_NOSCALE\" DECIMAL(15,0),\n"+
+            "    \"COL_DISTINCT\"        LONGVARBINARY,\n"+
+            "    \"COL_DOUBLE\"          DOUBLE,\n"+
+            "    \"COL_FLOAT\"           DOUBLE,\n"+
+            "    \"COL_INTEGER\"         INTEGER,\n"+
+            "    \"COL_JAVA_OBJECT\"     OBJECT,\n"+
+            "    \"COL_LONGVARBINARY\"   LONGVARBINARY,\n"+
+            "    \"COL_LONGVARCHAR\"     LONGVARCHAR,\n"+
+            "    \"COL_NULL\"            LONGVARBINARY,\n"+
+            "    \"COL_NUMERIC\"         NUMERIC(15,0),\n"+
+            "    \"COL_OTHER\"           OTHER,\n"+
+            "    \"COL_REAL\"            REAL,\n"+
+            "    \"COL_REF\"             LONGVARBINARY,\n"+
+            "    \"COL_SMALLINT\"        SMALLINT,\n"+
+            "    \"COL_STRUCT\"          LONGVARBINARY,\n"+
+            "    \"COL_TIME\"            TIME,\n"+
+            "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
+            "    \"COL_TINYINT\"         TINYINT,\n"+
+            "    \"COL_VARBINARY\"       VARBINARY(15),\n"+
+            "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the column constraints.
+     */
+    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"+
+            "(\n"+
+            "    \"COL_PK\"               VARCHAR(32),\n"+
+            "    \"COL_PK_AUTO_INCR\"     INTEGER IDENTITY,\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 IDENTITY,\n"+
+            "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+
+            "ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\";\n"+
+            "DROP TABLE \"table3\" IF EXISTS;\n"+
+            "DROP TABLE \"table2\" IF EXISTS;\n"+
+            "DROP TABLE \"table1\" IF EXISTS;\n"+
+            "CREATE TABLE \"table1\"\n"+
+            "(\n"+
+            "    \"COL_PK_1\"    VARCHAR(32) NOT NULL,\n"+
+            "    \"COL_PK_2\"    INTEGER,\n"+
+            "    \"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"+
+            ");\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"+
+            "    \"COL_FK_1\" INTEGER,\n"+
+            "    \"COL_FK_2\" VARCHAR(32) NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "CREATE TABLE \"table3\"\n"+
+            "(\n"+
+            "    \"COL_PK\" VARCHAR(16),\n"+
+            "    \"COL_FK\" INTEGER NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "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));
     }
 }

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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -41,43 +41,141 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE coltype;\n"+
+            "DROP TABLE \"coltype\";\n"+
             "COMMIT;\n"+
-            "CREATE TABLE coltype\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_BLOB            BLOB ,\n"+
-            "    COL_BOOLEAN         DECIMAL(1,0),\n"+
-            "    COL_CHAR            CHAR(15),\n"+
-            "    COL_CLOB            BLOB SUB_TYPE TEXT,\n"+
-            "    COL_DATALINK        BLOB,\n"+
-            "    COL_DATE            DATE,\n"+
-            "    COL_DECIMAL         DECIMAL(15,3),\n"+
-            "    COL_DECIMAL_NOSCALE DECIMAL(15,0),\n"+
-            "    COL_DISTINCT        BLOB,\n"+
-            "    COL_DOUBLE          DOUBLE PRECISION,\n"+
-            "    COL_FLOAT           DOUBLE PRECISION,\n"+
-            "    COL_INTEGER         INTEGER,\n"+
-            "    COL_JAVA_OBJECT     BLOB,\n"+
-            "    COL_LONGVARBINARY   BLOB,\n"+
-            "    COL_LONGVARCHAR     BLOB SUB_TYPE TEXT,\n"+
-            "    COL_NULL            BLOB,\n"+
-            "    COL_NUMERIC         NUMERIC(15,0),\n"+
-            "    COL_OTHER           BLOB,\n"+
-            "    COL_REAL            FLOAT,\n"+
-            "    COL_REF             BLOB,\n"+
-            "    COL_SMALLINT        SMALLINT,\n"+
-            "    COL_STRUCT          BLOB,\n"+
-            "    COL_TIME            TIME,\n"+
-            "    COL_TIMESTAMP       TIMESTAMP,\n"+
-            "    COL_TINYINT         SMALLINT,\n"+
-            "    COL_VARBINARY       VARCHAR(15) CHARACTER SET OCTETS,\n"+
-            "    COL_VARCHAR         VARCHAR(15)\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_BLOB\"            BLOB ,\n"+
+            "    \"COL_BOOLEAN\"         DECIMAL(1,0),\n"+
+            "    \"COL_CHAR\"            CHAR(15),\n"+
+            "    \"COL_CLOB\"            BLOB SUB_TYPE TEXT,\n"+
+            "    \"COL_DATALINK\"        BLOB,\n"+
+            "    \"COL_DATE\"            DATE,\n"+
+            "    \"COL_DECIMAL\"         DECIMAL(15,3),\n"+
+            "    \"COL_DECIMAL_NOSCALE\" DECIMAL(15,0),\n"+
+            "    \"COL_DISTINCT\"        BLOB,\n"+
+            "    \"COL_DOUBLE\"          DOUBLE PRECISION,\n"+
+            "    \"COL_FLOAT\"           DOUBLE PRECISION,\n"+
+            "    \"COL_INTEGER\"         INTEGER,\n"+
+            "    \"COL_JAVA_OBJECT\"     BLOB,\n"+
+            "    \"COL_LONGVARBINARY\"   BLOB,\n"+
+            "    \"COL_LONGVARCHAR\"     BLOB SUB_TYPE TEXT,\n"+
+            "    \"COL_NULL\"            BLOB,\n"+
+            "    \"COL_NUMERIC\"         NUMERIC(15,0),\n"+
+            "    \"COL_OTHER\"           BLOB,\n"+
+            "    \"COL_REAL\"            FLOAT,\n"+
+            "    \"COL_REF\"             BLOB,\n"+
+            "    \"COL_SMALLINT\"        SMALLINT,\n"+
+            "    \"COL_STRUCT\"          BLOB,\n"+
+            "    \"COL_TIME\"            TIME,\n"+
+            "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
+            "    \"COL_TINYINT\"         SMALLINT,\n"+
+            "    \"COL_VARBINARY\"       VARCHAR(15) CHARACTER SET OCTETS,\n"+
+            "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n"+
             "COMMIT;\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the column constraints.
+     */
+    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"+
+            "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_DEFAULT\" DOUBLE PRECISION DEFAULT '-2.0' NOT NULL,\n"+
+            "    \"COL_DEFAULT\"          CHAR(4) DEFAULT 'test',\n"+
+            "    \"COL_AUTO_INCR\"        DECIMAL(38,0),\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"+
+            "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"+
+            "CREATE GENERATOR \"gen_constraints_COL_AUTO_INCR\";\n" +
+            "COMMIT;\n"+
+            "SET 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",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        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_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"+
+            "    \"COL_FK_1\" INTEGER,\n"+
+            "    \"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",
+            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
     }
 }

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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -41,7 +41,9 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'coltype')\n"+
+            "SET quoted_identifier on;\n"+
+            "SET quoted_identifier on;\n"+
+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = \"coltype\")\n"+
             "BEGIN\n"+
             "     DECLARE @reftable nvarchar(60), @constraintname nvarchar(60)\n"+
             "     DECLARE refcursor CURSOR FOR\n"+
@@ -53,7 +55,7 @@
             "       where tables.id = ref.rkeyid\n"+
             "         and cons.id = ref.constid\n"+
             "         and reftables.id = ref.fkeyid\n"+
-            "         and tables.name = 'coltype'\n"+
+            "         and tables.name = \"coltype\"\n"+
             "     OPEN refcursor\n"+
             "     FETCH NEXT from refcursor into @reftable, @constraintname\n"+
             "     while @@FETCH_STATUS = 0\n"+
@@ -63,42 +65,209 @@
             "     END\n"+
             "     CLOSE refcursor\n"+
             "     DEALLOCATE refcursor\n"+
-            "     DROP TABLE coltype\n"+
+            "     DROP TABLE \"coltype\"\n"+
             "END;\n"+
-            "CREATE TABLE coltype\n"+
+            "SET quoted_identifier on;\n"+
+            "CREATE TABLE \"coltype\"\n"+
             "(\n"+
-            "    COL_ARRAY           IMAGE,\n"+
-            "    COL_BIGINT          DECIMAL(19,0),\n"+
-            "    COL_BINARY          BINARY,\n"+
-            "    COL_BIT             BIT,\n"+
-            "    COL_BLOB            IMAGE,\n"+
-            "    COL_BOOLEAN         BIT,\n"+
-            "    COL_CHAR            CHAR(15),\n"+
-            "    COL_CLOB            TEXT,\n"+
-            "    COL_DATALINK        IMAGE,\n"+
-            "    COL_DATE            DATETIME,\n"+
-            "    COL_DECIMAL         DECIMAL(15,3),\n"+
-            "    COL_DECIMAL_NOSCALE DECIMAL(15,0),\n"+
-            "    COL_DISTINCT        IMAGE,\n"+
-            "    COL_DOUBLE          FLOAT,\n"+
-            "    COL_FLOAT           FLOAT,\n"+
-            "    COL_INTEGER         INT,\n"+
-            "    COL_JAVA_OBJECT     IMAGE,\n"+
-            "    COL_LONGVARBINARY   IMAGE,\n"+
-            "    COL_LONGVARCHAR     TEXT,\n"+
-            "    COL_NULL            IMAGE,\n"+
-            "    COL_NUMERIC         NUMERIC(15,0),\n"+
-            "    COL_OTHER           IMAGE,\n"+
-            "    COL_REAL            REAL,\n"+
-            "    COL_REF             IMAGE,\n"+
-            "    COL_SMALLINT        SMALLINT,\n"+
-            "    COL_STRUCT          IMAGE,\n"+
-            "    COL_TIME            DATETIME,\n"+
-            "    COL_TIMESTAMP       DATETIME,\n"+
-            "    COL_TINYINT         SMALLINT,\n"+
-            "    COL_VARBINARY       VARBINARY(15),\n"+
-            "    COL_VARCHAR         VARCHAR(15)\n"+
+            "    \"COL_ARRAY\"           IMAGE,\n"+
+            "    \"COL_BIGINT\"          DECIMAL(19,0),\n"+
+            "    \"COL_BINARY\"          BINARY,\n"+
+            "    \"COL_BIT\"             BIT,\n"+
+            "    \"COL_BLOB\"            IMAGE,\n"+
+            "    \"COL_BOOLEAN\"         BIT,\n"+
+            "    \"COL_CHAR\"            CHAR(15),\n"+
+            "    \"COL_CLOB\"            TEXT,\n"+
+            "    \"COL_DATALINK\"        IMAGE,\n"+
+            "    \"COL_DATE\"            DATETIME,\n"+
+            "    \"COL_DECIMAL\"         DECIMAL(15,3),\n"+
+            "    \"COL_DECIMAL_NOSCALE\" DECIMAL(15,0),\n"+
+            "    \"COL_DISTINCT\"        IMAGE,\n"+
+            "    \"COL_DOUBLE\"          FLOAT,\n"+
+            "    \"COL_FLOAT\"           FLOAT,\n"+
+            "    \"COL_INTEGER\"         INT,\n"+
+            "    \"COL_JAVA_OBJECT\"     IMAGE,\n"+
+            "    \"COL_LONGVARBINARY\"   IMAGE,\n"+
+            "    \"COL_LONGVARCHAR\"     TEXT,\n"+
+            "    \"COL_NULL\"            IMAGE,\n"+
+            "    \"COL_NUMERIC\"         NUMERIC(15,0),\n"+
+            "    \"COL_OTHER\"           IMAGE,\n"+
+            "    \"COL_REAL\"            REAL,\n"+
+            "    \"COL_REF\"             IMAGE,\n"+
+            "    \"COL_SMALLINT\"        SMALLINT,\n"+
+            "    \"COL_STRUCT\"          IMAGE,\n"+
+            "    \"COL_TIME\"            DATETIME,\n"+
+            "    \"COL_TIMESTAMP\"       DATETIME,\n"+
+            "    \"COL_TINYINT\"         SMALLINT,\n"+
+            "    \"COL_VARBINARY\"       VARBINARY(15),\n"+
+            "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+
+    /**
+     * Tests the column constraints.
+     */
+    public void testColumnConstraints() throws Exception
+    {
+        // this is not valid sql as a table can have only one identity column at most 
+        assertEqualsIgnoringWhitespaces(
+            "SET quoted_identifier on;\n"+
+            "SET quoted_identifier on;\n"+
+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = \"constraints\")\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 = \"constraints\"\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 \"constraints\"\n"+
+            "END;\n"+
+            "SET quoted_identifier on;\n"+
+            "CREATE TABLE \"constraints\"\n"+
+            "(\n"+
+            "    \"COL_PK\"               VARCHAR(32),\n"+
+            "    \"COL_PK_AUTO_INCR\"     INT IDENTITY(1,1),\n"+
+            "    \"COL_NOT_NULL\"         BINARY(100) NOT NULL,\n"+
+            "    \"COL_NOT_NULL_DEFAULT\" FLOAT DEFAULT '-2.0' NOT NULL,\n"+
+            "    \"COL_DEFAULT\"          CHAR(4) DEFAULT 'test',\n"+
+            "    \"COL_AUTO_INCR\"        DECIMAL(19,0) IDENTITY(1,1),\n"+
+            "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "SET quoted_identifier on;\n"+
+            "ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+
+            "SET quoted_identifier on;\n"+
+            "ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\";\n"+
+            "SET quoted_identifier on;\n"+
+            "SET quoted_identifier on;\n"+
+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = \"table3\")\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 = \"table3\"\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 \"table3\"\n"+
+            "END;\n"+
+            "SET quoted_identifier on;\n"+
+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = \"table2\")\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 = \"table2\"\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 \"table2\"\n"+
+            "END;\n"+
+            "SET quoted_identifier on;\n"+
+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = \"table1\")\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 = \"table1\"\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 \"table1\"\n"+
+            "END;\n"+
+            "SET quoted_identifier on;\n"+
+            "CREATE TABLE \"table1\"\n"+
+            "(\n"+
+            "    \"COL_PK_1\"    VARCHAR(32) NOT NULL,\n"+
+            "    \"COL_PK_2\"    INT,\n"+
+            "    \"COL_INDEX_1\" BINARY(100) NOT NULL,\n"+
+            "    \"COL_INDEX_2\" FLOAT 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"+
+            "SET quoted_identifier on;\n"+
+            "CREATE TABLE \"table2\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INT,\n"+
+            "    \"COL_FK_1\" INT,\n"+
+            "    \"COL_FK_2\" VARCHAR(32) NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "SET quoted_identifier on;\n"+
+            "CREATE TABLE \"table3\"\n"+
+            "(\n"+
+            "    \"COL_PK\" VARCHAR(16),\n"+
+            "    \"COL_FK\" INT NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "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));
     }
 }

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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -41,41 +41,101 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE coltype CASCADE;\n"+
-            "CREATE TABLE coltype\n"+
+            "DROP TABLE \"coltype\" CASCADE;\n"+
+            "CREATE TABLE \"coltype\"\n"+
             "(\n"+
-            "    COL_ARRAY           LONG BYTE,\n"+
-            "    COL_BIGINT          FIXED(38,0),\n"+
-            "    COL_BINARY          LONG BYTE,\n"+
-            "    COL_BIT             BOOLEAN,\n"+
-            "    COL_BLOB            LONG BYTE,\n"+
-            "    COL_BOOLEAN         BOOLEAN,\n"+
-            "    COL_CHAR            CHAR(15),\n"+
-            "    COL_CLOB            LONG,\n"+
-            "    COL_DATALINK        LONG BYTE,\n"+
-            "    COL_DATE            DATE,\n"+
-            "    COL_DECIMAL         DECIMAL(15,3),\n"+
-            "    COL_DECIMAL_NOSCALE DECIMAL(15,0),\n"+
-            "    COL_DISTINCT        LONG BYTE,\n"+
-            "    COL_DOUBLE          DOUBLE PRECISION,\n"+
-            "    COL_FLOAT           DOUBLE PRECISION,\n"+
-            "    COL_INTEGER         INTEGER,\n"+
-            "    COL_JAVA_OBJECT     LONG BYTE,\n"+
-            "    COL_LONGVARBINARY   LONG BYTE,\n"+
-            "    COL_LONGVARCHAR     LONG VARCHAR,\n"+
-            "    COL_NULL            LONG BYTE,\n"+
-            "    COL_NUMERIC         DECIMAL(15,0),\n"+
-            "    COL_OTHER           LONG BYTE,\n"+
-            "    COL_REAL            REAL,\n"+
-            "    COL_REF             LONG BYTE,\n"+
-            "    COL_SMALLINT        SMALLINT,\n"+
-            "    COL_STRUCT          LONG BYTE,\n"+
-            "    COL_TIME            TIME,\n"+
-            "    COL_TIMESTAMP       TIMESTAMP,\n"+
-            "    COL_TINYINT         SMALLINT,\n"+
-            "    COL_VARBINARY       LONG BYTE,\n"+
-            "    COL_VARCHAR         VARCHAR(15)\n"+
+            "    \"COL_ARRAY\"           LONG BYTE,\n"+
+            "    \"COL_BIGINT\"          FIXED(38,0),\n"+
+            "    \"COL_BINARY\"          LONG BYTE,\n"+
+            "    \"COL_BIT\"             BOOLEAN,\n"+
+            "    \"COL_BLOB\"            LONG BYTE,\n"+
+            "    \"COL_BOOLEAN\"         BOOLEAN,\n"+
+            "    \"COL_CHAR\"            CHAR(15),\n"+
+            "    \"COL_CLOB\"            LONG,\n"+
+            "    \"COL_DATALINK\"        LONG BYTE,\n"+
+            "    \"COL_DATE\"            DATE,\n"+
+            "    \"COL_DECIMAL\"         DECIMAL(15,3),\n"+
+            "    \"COL_DECIMAL_NOSCALE\" DECIMAL(15,0),\n"+
+            "    \"COL_DISTINCT\"        LONG BYTE,\n"+
+            "    \"COL_DOUBLE\"          DOUBLE PRECISION,\n"+
+            "    \"COL_FLOAT\"           DOUBLE PRECISION,\n"+
+            "    \"COL_INTEGER\"         INTEGER,\n"+
+            "    \"COL_JAVA_OBJECT\"     LONG BYTE,\n"+
+            "    \"COL_LONGVARBINARY\"   LONG BYTE,\n"+
+            "    \"COL_LONGVARCHAR\"     LONG VARCHAR,\n"+
+            "    \"COL_NULL\"            LONG BYTE,\n"+
+            "    \"COL_NUMERIC\"         DECIMAL(15,0),\n"+
+            "    \"COL_OTHER\"           LONG BYTE,\n"+
+            "    \"COL_REAL\"            REAL,\n"+
+            "    \"COL_REF\"             LONG BYTE,\n"+
+            "    \"COL_SMALLINT\"        SMALLINT,\n"+
+            "    \"COL_STRUCT\"          LONG BYTE,\n"+
+            "    \"COL_TIME\"            TIME,\n"+
+            "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
+            "    \"COL_TINYINT\"         SMALLINT,\n"+
+            "    \"COL_VARBINARY\"       LONG BYTE,\n"+
+            "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the column constraints.
+     */
+    public void testColumnConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE \"constraints\" CASCADE;\n" +
+            "CREATE TABLE \"constraints\"\n"+
+            "(\n"+
+            "    \"COL_PK\"               VARCHAR(32),\n"+
+            "    \"COL_PK_AUTO_INCR\"     INTEGER DEFAULT SERIAL(1),\n"+
+            "    \"COL_NOT_NULL\"         LONG BYTE 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\"        FIXED(38,0) DEFAULT SERIAL(1),\n"+
+            "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+
+            "ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_COL_FK_COL_FK_2_table1\";\n"+
+            "DROP TABLE \"table3\" CASCADE;\n"+
+            "DROP TABLE \"table2\" CASCADE;\n"+
+            "DROP TABLE \"table1\" CASCADE;\n"+
+            "CREATE TABLE \"table1\"\n"+
+            "(\n"+
+            "    \"COL_PK_1\"    VARCHAR(32) NOT NULL,\n"+
+            "    \"COL_PK_2\"    INTEGER,\n"+
+            "    \"COL_INDEX_1\" LONG BYTE 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"+
+            "CREATE TABLE \"table2\"\n"+
+            "(\n"+
+            "    \"COL_PK\"   INTEGER,\n"+
+            "    \"COL_FK_1\" INTEGER,\n"+
+            "    \"COL_FK_2\" VARCHAR(32) NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "CREATE TABLE \"table3\"\n"+
+            "(\n"+
+            "    \"COL_PK\" VARCHAR(16),\n"+
+            "    \"COL_FK\" INTEGER NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "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));
     }
 }

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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -41,41 +41,103 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE IF EXISTS coltype;\n"+
-            "CREATE TABLE coltype\n"+
+            "DROP TABLE IF EXISTS \"coltype\";\n"+
+            "CREATE TABLE \"coltype\"\n"+
             "(\n"+
-            "    COL_ARRAY           BLOB,\n"+
-            "    COL_BIGINT          BIGINT,\n"+
-            "    COL_BINARY          BINARY,\n"+
-            "    COL_BIT             BOOLEAN,\n"+
-            "    COL_BLOB            BLOB,\n"+
-            "    COL_BOOLEAN         BOOLEAN,\n"+
-            "    COL_CHAR            CHAR(15),\n"+
-            "    COL_CLOB            CLOB,\n"+
-            "    COL_DATALINK        BLOB,\n"+
-            "    COL_DATE            DATE,\n"+
-            "    COL_DECIMAL         DECIMAL(15,3),\n"+
-            "    COL_DECIMAL_NOSCALE DECIMAL(15,0),\n"+
-            "    COL_DISTINCT        BLOB,\n"+
-            "    COL_DOUBLE          DOUBLE,\n"+
-            "    COL_FLOAT           DOUBLE,\n"+
-            "    COL_INTEGER         INTEGER,\n"+
-            "    COL_JAVA_OBJECT     JAVA_OBJECT,\n"+
-            "    COL_LONGVARBINARY   LONGVARBINARY,\n"+
-            "    COL_LONGVARCHAR     LONGVARCHAR,\n"+
-            "    COL_NULL            BLOB,\n"+
-            "    COL_NUMERIC         NUMERIC(15,0),\n"+
-            "    COL_OTHER           BLOB,\n"+
-            "    COL_REAL            REAL,\n"+
-            "    COL_REF             BLOB,\n"+
-            "    COL_SMALLINT        SMALLINT,\n"+
-            "    COL_STRUCT          BLOB,\n"+
-            "    COL_TIME            TIME,\n"+
-            "    COL_TIMESTAMP       TIMESTAMP,\n"+
-            "    COL_TINYINT         TINYINT,\n"+
-            "    COL_VARBINARY       VARBINARY(15),\n"+
-            "    COL_VARCHAR         VARCHAR(15)\n"+
+            "    \"COL_ARRAY\"           BLOB,\n"+
+            "    \"COL_BIGINT\"          BIGINT,\n"+
+            "    \"COL_BINARY\"          BINARY,\n"+
+            "    \"COL_BIT\"             BOOLEAN,\n"+
+            "    \"COL_BLOB\"            BLOB,\n"+
+            "    \"COL_BOOLEAN\"         BOOLEAN,\n"+
+            "    \"COL_CHAR\"            CHAR(15),\n"+
+            "    \"COL_CLOB\"            CLOB,\n"+
+            "    \"COL_DATALINK\"        BLOB,\n"+
+            "    \"COL_DATE\"            DATE,\n"+
+            "    \"COL_DECIMAL\"         DECIMAL(15,3),\n"+
+            "    \"COL_DECIMAL_NOSCALE\" DECIMAL(15,0),\n"+
+            "    \"COL_DISTINCT\"        BLOB,\n"+
+            "    \"COL_DOUBLE\"          DOUBLE,\n"+
+            "    \"COL_FLOAT\"           DOUBLE,\n"+
+            "    \"COL_INTEGER\"         INTEGER,\n"+
+            "    \"COL_JAVA_OBJECT\"     JAVA_OBJECT,\n"+
+            "    \"COL_LONGVARBINARY\"   LONGVARBINARY,\n"+
+            "    \"COL_LONGVARCHAR\"     LONGVARCHAR,\n"+
+            "    \"COL_NULL\"            BLOB,\n"+
+            "    \"COL_NUMERIC\"         NUMERIC(15,0),\n"+
+            "    \"COL_OTHER\"           BLOB,\n"+
+            "    \"COL_REAL\"            REAL,\n"+
+            "    \"COL_REF\"             BLOB,\n"+
+            "    \"COL_SMALLINT\"        SMALLINT,\n"+
+            "    \"COL_STRUCT\"          BLOB,\n"+
+            "    \"COL_TIME\"            TIME,\n"+
+            "    \"COL_TIMESTAMP\"       TIMESTAMP,\n"+
+            "    \"COL_TINYINT\"         TINYINT,\n"+
+            "    \"COL_VARBINARY\"       VARBINARY(15),\n"+
+            "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the column constraints.
+     */
+    public void testColumnConstraints() throws Exception
+    {
+        // note that this is not valid SQL as obviously only one auto increment field
+        // can be defined for each table
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE IF EXISTS \"constraints\";\n" +
+            "CREATE TABLE \"constraints\"\n"+
+            "(\n"+
+            "    \"COL_PK\"               VARCHAR(32),\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"+
+            "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+
+            "ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\";\n"+
+            "DROP TABLE IF EXISTS \"table3\";\n"+
+            "DROP TABLE IF EXISTS \"table2\";\n"+
+            "DROP TABLE IF EXISTS \"table1\";\n"+
+            "CREATE TABLE \"table1\"\n"+
+            "(\n"+
+            "    \"COL_PK_1\"    VARCHAR(32) NOT NULL,\n"+
+            "    \"COL_PK_2\"    INTEGER,\n"+
+            "    \"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"+
+            ");\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"+
+            "    \"COL_FK_1\" INTEGER,\n"+
+            "    \"COL_FK_2\" VARCHAR(32) NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "CREATE TABLE \"table3\"\n"+
+            "(\n"+
+            "    \"COL_PK\" VARCHAR(16),\n"+
+            "    \"COL_FK\" INTEGER NOT NULL,\n"+
+            "    PRIMARY KEY (\"COL_PK\")\n"+
+            ");\n"+
+            "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));
     }
 }

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=289996&r1=289995&r2=289996&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 Sun Sep 18 16:00:38 2005
@@ -41,41 +41,101 @@
     public void testColumnTypes() throws Exception
     {
         assertEqualsIgnoringWhitespaces(
-            "DROP TABLE IF EXISTS coltype;\n"+
-            "CREATE TABLE coltype\n"+
+            "DROP TABLE IF EXISTS `coltype`;\n"+
+            "CREATE TABLE `coltype`\n"+
             "(\n"+
-            "    COL_ARRAY           LONGBLOB,\n"+
-            "    COL_BIGINT          BIGINT,\n"+
-            "    COL_BINARY          CHAR(254) BINARY,\n"+
-            "    COL_BIT             TINYINT(1),\n"+
-            "    COL_BLOB            LONGBLOB,\n"+
-            "    COL_BOOLEAN         TINYINT(1),\n"+
-            "    COL_CHAR            CHAR(15),\n"+
-            "    COL_CLOB            LONGTEXT,\n"+
-            "    COL_DATALINK        MEDIUMBLOB,\n"+
-            "    COL_DATE            DATE,\n"+
-            "    COL_DECIMAL         DECIMAL(15,3),\n"+
-            "    COL_DECIMAL_NOSCALE DECIMAL(15,0),\n"+
-            "    COL_DISTINCT        LONGBLOB,\n"+
-            "    COL_DOUBLE          DOUBLE,\n"+
-            "    COL_FLOAT           DOUBLE,\n"+
-            "    COL_INTEGER         INTEGER,\n"+
-            "    COL_JAVA_OBJECT     LONGBLOB,\n"+
-            "    COL_LONGVARBINARY   MEDIUMBLOB,\n"+
-            "    COL_LONGVARCHAR     MEDIUMTEXT,\n"+
-            "    COL_NULL            MEDIUMBLOB,\n"+
-            "    COL_NUMERIC         DECIMAL(15,0),\n"+
-            "    COL_OTHER           LONGBLOB,\n"+
-            "    COL_REAL            FLOAT,\n"+
-            "    COL_REF             MEDIUMBLOB,\n"+
-            "    COL_SMALLINT        SMALLINT,\n"+
-            "    COL_STRUCT          LONGBLOB,\n"+
-            "    COL_TIME            TIME,\n"+
-            "    COL_TIMESTAMP       DATETIME,\n"+
-            "    COL_TINYINT         TINYINT,\n"+
-            "    COL_VARBINARY       VARCHAR(15) BINARY,\n"+
-            "    COL_VARCHAR         VARCHAR(15)\n"+
+            "    `COL_ARRAY`           LONGBLOB,\n"+
+            "    `COL_BIGINT`          BIGINT,\n"+
+            "    `COL_BINARY`          CHAR(254) BINARY,\n"+
+            "    `COL_BIT`             TINYINT(1),\n"+
+            "    `COL_BLOB`            LONGBLOB,\n"+
+            "    `COL_BOOLEAN`         TINYINT(1),\n"+
+            "    `COL_CHAR`            CHAR(15),\n"+
+            "    `COL_CLOB`            LONGTEXT,\n"+
+            "    `COL_DATALINK`        MEDIUMBLOB,\n"+
+            "    `COL_DATE`            DATE,\n"+
+            "    `COL_DECIMAL`         DECIMAL(15,3),\n"+
+            "    `COL_DECIMAL_NOSCALE` DECIMAL(15,0),\n"+
+            "    `COL_DISTINCT`        LONGBLOB,\n"+
+            "    `COL_DOUBLE`          DOUBLE,\n"+
+            "    `COL_FLOAT`           DOUBLE,\n"+
+            "    `COL_INTEGER`         INTEGER,\n"+
+            "    `COL_JAVA_OBJECT`     LONGBLOB,\n"+
+            "    `COL_LONGVARBINARY`   MEDIUMBLOB,\n"+
+            "    `COL_LONGVARCHAR`     MEDIUMTEXT,\n"+
+            "    `COL_NULL`            MEDIUMBLOB,\n"+
+            "    `COL_NUMERIC`         DECIMAL(15,0),\n"+
+            "    `COL_OTHER`           LONGBLOB,\n"+
+            "    `COL_REAL`            FLOAT,\n"+
+            "    `COL_REF`             MEDIUMBLOB,\n"+
+            "    `COL_SMALLINT`        SMALLINT,\n"+
+            "    `COL_STRUCT`          LONGBLOB,\n"+
+            "    `COL_TIME`            TIME,\n"+
+            "    `COL_TIMESTAMP`       DATETIME,\n"+
+            "    `COL_TINYINT`         TINYINT,\n"+
+            "    `COL_VARBINARY`       VARCHAR(15) BINARY,\n"+
+            "    `COL_VARCHAR`         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase());
+            createTestDatabase(COLUMN_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the column constraints.
+     */
+    public void testColumnConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "DROP TABLE IF EXISTS `constraints`;\n" +
+            "CREATE TABLE `constraints`\n"+
+            "(\n"+
+            "    `COL_PK`               VARCHAR(32),\n"+
+            "    `COL_PK_AUTO_INCR`     INTEGER AUTO_INCREMENT,\n"+
+            "    `COL_NOT_NULL`         CHAR(100) BINARY 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 AUTO_INCREMENT,\n"+
+            "    PRIMARY KEY (`COL_PK`, `COL_PK_AUTO_INCR`)\n"+
+            ");\n",
+            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+    }
+
+    /**
+     * Tests the table constraints.
+     */
+    public void testTableConstraints() throws Exception
+    {
+        assertEqualsIgnoringWhitespaces(
+            "ALTER TABLE `table3` DROP CONSTRAINT `testfk`;\n"+
+            "ALTER TABLE `table2` DROP CONSTRAINT `table2_FK_COL_FK_1_COL_FK_2_table1`;\n"+
+            "DROP TABLE IF EXISTS `table3`;\n"+
+            "DROP TABLE IF EXISTS `table2`;\n"+
+            "DROP TABLE IF EXISTS `table1`;\n"+
+            "CREATE TABLE `table1`\n"+
+            "(\n"+
+            "    `COL_PK_1`    VARCHAR(32) NOT NULL,\n"+
+            "    `COL_PK_2`    INTEGER,\n"+
+            "    `COL_INDEX_1` CHAR(100) BINARY 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"+
+            ");\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"+
+            "    `COL_FK_1` INTEGER,\n"+
+            "    `COL_FK_2` VARCHAR(32) NOT NULL,\n"+
+            "    PRIMARY KEY (`COL_PK`)\n"+
+            ");\n"+
+            "CREATE TABLE `table3`\n"+
+            "(\n"+
+            "    `COL_PK` VARCHAR(16),\n"+
+            "    `COL_FK` INTEGER NOT NULL,\n"+
+            "    PRIMARY KEY (`COL_PK`)\n"+
+            ");\n"+
+            "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));
     }
 }



Mime
View raw message