@@ -47,6 +47,19 @@ public void testCreateTableAsSelect2() throws JSQLParserException {
4747 }
4848
4949 public void testCreateTable () throws JSQLParserException {
50+ String statement = "CREATE TABLE mytab (mycol a (10, 20) c nm g, mycol2 mypar1 mypar2 (23,323,3) asdf ('23','123') dasd, "
51+ + "PRIMARY KEY (mycol2, mycol)) type = myisam" ;
52+ CreateTable createTable = (CreateTable ) parserManager .parse (new StringReader (statement ));
53+ assertEquals (2 , createTable .getColumnDefinitions ().size ());
54+ assertFalse (createTable .isUnlogged ());
55+ assertEquals ("mycol" , ((ColumnDefinition ) createTable .getColumnDefinitions ().get (0 )).getColumnName ());
56+ assertEquals ("mycol2" , ((ColumnDefinition ) createTable .getColumnDefinitions ().get (1 )).getColumnName ());
57+ assertEquals ("PRIMARY KEY" , ((Index ) createTable .getIndexes ().get (0 )).getType ());
58+ assertEquals ("mycol" , ((Index ) createTable .getIndexes ().get (0 )).getColumnsNames ().get (1 ));
59+ assertEquals (statement , "" + createTable );
60+ }
61+
62+ public void testCreateTableUnlogged () throws JSQLParserException {
5063 String statement = "CREATE UNLOGGED TABLE mytab (mycol a (10, 20) c nm g, mycol2 mypar1 mypar2 (23,323,3) asdf ('23','123') dasd, "
5164 + "PRIMARY KEY (mycol2, mycol)) type = myisam" ;
5265 CreateTable createTable = (CreateTable ) parserManager .parse (new StringReader (statement ));
@@ -58,6 +71,11 @@ public void testCreateTable() throws JSQLParserException {
5871 assertEquals ("mycol" , ((Index ) createTable .getIndexes ().get (0 )).getColumnsNames ().get (1 ));
5972 assertEquals (statement , "" + createTable );
6073 }
74+
75+ public void testCreateTableUnlogged2 () throws JSQLParserException {
76+ String statement = "CREATE UNLOGGED TABLE mytab (mycol a (10, 20) c nm g, mycol2 mypar1 mypar2 (23,323,3) asdf ('23','123') dasd, PRIMARY KEY (mycol2, mycol))" ;
77+ assertSqlCanBeParsedAndDeparsed (statement );
78+ }
6179
6280 public void testCreateTableForeignKey () throws JSQLParserException {
6381 String statement = "CREATE TABLE test (id INT UNSIGNED NOT NULL AUTO_INCREMENT, string VARCHAR (20), user_id INT UNSIGNED, PRIMARY KEY (id), FOREIGN KEY (user_id) REFERENCES ra_user(id))" ;
0 commit comments