@@ -169,16 +169,28 @@ public void testCreateTableColumnValue() throws JSQLParserException {
169169 }
170170
171171 public void testCreateTableForeignKey5 () throws JSQLParserException {
172- assertSqlCanBeParsedAndDeparsed ("CREATE TABLE IF NOT EXISTS table1 (id INTEGER PRIMARY KEY AUTO_INCREMENT, aid INTEGER REFERENCES accounts ON aid ON DELETE CASCADE, name STRING, lastname STRING)" );
173- }
174-
175- public void testCreateTableForeignKey6 () throws JSQLParserException {
176- assertSqlCanBeParsedAndDeparsed ("CREATE TABLE test (id long, fkey long references another_table (id))" );
177- }
172+ assertSqlCanBeParsedAndDeparsed ("CREATE TABLE IF NOT EXISTS table1 (id INTEGER PRIMARY KEY AUTO_INCREMENT, aid INTEGER REFERENCES accounts ON aid ON DELETE CASCADE, name STRING, lastname STRING)" );
173+ }
178174
179- public void testCreateTableMySqlOnUpdateCurrentTimestamp () throws JSQLParserException {
180- assertSqlCanBeParsedAndDeparsed ("CREATE TABLE test (applied timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)" );
181- }
175+ public void testCreateTableForeignKey6 () throws JSQLParserException {
176+ assertSqlCanBeParsedAndDeparsed ("CREATE TABLE test (id long, fkey long references another_table (id))" );
177+ }
178+
179+ public void testMySqlCreateTableOnUpdateCurrentTimestamp () throws JSQLParserException {
180+ assertSqlCanBeParsedAndDeparsed ("CREATE TABLE test (applied timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)" );
181+ }
182+
183+ public void testMySqlCreateTableWithConstraintWithCascade () throws JSQLParserException {
184+ assertSqlCanBeParsedAndDeparsed ("CREATE TABLE table1 (id INT (10) UNSIGNED NOT NULL AUTO_INCREMENT, t2_id INT (10) UNSIGNED DEFAULT NULL, t3_id INT (10) UNSIGNED DEFAULT NULL, t4_id INT (10) UNSIGNED NOT NULL, PRIMARY KEY (id), KEY fkc_table1_t4 (t4_id), KEY fkc_table1_t2 (t2_id), KEY fkc_table1_t3 (t3_id), CONSTRAINT fkc_table1_t2 FOREIGN KEY (t2_id) REFERENCES table_two(t2o_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT fkc_table1_t3 FOREIGN KEY (t3_id) REFERENCES table_three(t3o_id) ON UPDATE CASCADE, CONSTRAINT fkc_table1_t4 FOREIGN KEY (t4_id) REFERENCES table_four(t4o_id) ON DELETE CASCADE) ENGINE = InnoDB AUTO_INCREMENT = 8761 DEFAULT CHARSET = utf8" );
185+ }
186+
187+ public void testMySqlCreateTableWithConstraintWithNoAction () throws JSQLParserException {
188+ assertSqlCanBeParsedAndDeparsed ("CREATE TABLE table1 (id INT (10) UNSIGNED NOT NULL AUTO_INCREMENT, t2_id INT (10) UNSIGNED DEFAULT NULL, t3_id INT (10) UNSIGNED DEFAULT NULL, t4_id INT (10) UNSIGNED NOT NULL, PRIMARY KEY (id), KEY fkc_table1_t4 (t4_id), KEY fkc_table1_t2 (t2_id), KEY fkc_table1_t3 (t3_id), CONSTRAINT fkc_table1_t2 FOREIGN KEY (t2_id) REFERENCES table_two(t2o_id) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fkc_table1_t3 FOREIGN KEY (t3_id) REFERENCES table_three(t3o_id) ON UPDATE NO ACTION, CONSTRAINT fkc_table1_t4 FOREIGN KEY (t4_id) REFERENCES table_four(t4o_id) ON DELETE NO ACTION) ENGINE = InnoDB AUTO_INCREMENT = 8761 DEFAULT CHARSET = utf8" );
189+ }
190+
191+ public void testMySqlCreateTableWithTextIndexes () throws JSQLParserException {
192+ assertSqlCanBeParsedAndDeparsed ("CREATE TABLE table2 (id INT (10) UNSIGNED NOT NULL AUTO_INCREMENT, name TEXT, url TEXT, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id), FULLTEXT KEY idx_table2_name (name)) ENGINE = InnoDB AUTO_INCREMENT = 7334 DEFAULT CHARSET = utf8" );
193+ }
182194
183195 public void testRUBiSCreateList () throws Exception {
184196 BufferedReader in = new BufferedReader (new InputStreamReader (CreateTableTest .class .getResourceAsStream ("/RUBiS-create-requests.txt" )));
0 commit comments