Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -2522,6 +2522,10 @@ String CreateParameter():
tk=<K_NOT> { retval = tk.image; }
|
tk=<K_PRIMARY> { retval = tk.image; }
|
tk=<K_FOREIGN> { retval=tk.image; }
|
tk=<K_REFERENCES> { retval=tk.image; }
|
tk=<K_KEY> { retval = tk.image; }
|
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/net/sf/jsqlparser/test/create/CreateTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ public void testCreateTableForeignKey2() throws JSQLParserException {
String statement = "CREATE TABLE test (id INT UNSIGNED NOT NULL AUTO_INCREMENT, string VARCHAR (20), user_id INT UNSIGNED, PRIMARY KEY (id), CONSTRAINT fkIdx FOREIGN KEY (user_id) REFERENCES ra_user(id))";
assertSqlCanBeParsedAndDeparsed(statement);
}

public void testCreateTableForeignKey3() throws JSQLParserException {
String statement = "CREATE TABLE test (id INT UNSIGNED NOT NULL AUTO_INCREMENT, string VARCHAR (20), user_id INT UNSIGNED REFERENCES ra_user(id), PRIMARY KEY (id))";
assertSqlCanBeParsedAndDeparsed(statement,true);
}

public void testCreateTableForeignKey4() throws JSQLParserException {
String statement = "CREATE TABLE test (id INT UNSIGNED NOT NULL AUTO_INCREMENT, string VARCHAR (20), user_id INT UNSIGNED FOREIGN KEY REFERENCES ra_user(id), PRIMARY KEY (id))";
assertSqlCanBeParsedAndDeparsed(statement,true);
}

public void testCreateTablePrimaryKey() throws JSQLParserException {
String statement = "CREATE TABLE test (id INT UNSIGNED NOT NULL AUTO_INCREMENT, string VARCHAR (20), user_id INT UNSIGNED, CONSTRAINT pk_name PRIMARY KEY (id))";
Expand Down