Skip to content

Commit 02be9cd

Browse files
committed
fixes #93
1 parent e902a41 commit 02be9cd

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,8 +2325,9 @@ CreateView CreateView():
23252325

23262326
String CreateParameter():
23272327
{
2328-
String retval = null;
2328+
String retval = "";
23292329
Token tk = null;
2330+
Token sign = null;
23302331
}
23312332
{
23322333
(
@@ -2342,9 +2343,12 @@ String CreateParameter():
23422343
|
23432344
tk=<S_CHAR_LITERAL> { retval = tk.image; }
23442345
|
2345-
tk=<S_LONG> { retval = tk.image; }
2346-
|
2347-
tk=<S_DOUBLE> { retval = tk.image; }
2346+
("+" {retval = "+";} | "-" {retval = "-";})?
2347+
(
2348+
tk=<S_LONG> { retval += tk.image; }
2349+
|
2350+
tk=<S_DOUBLE> { retval += tk.image; }
2351+
)
23482352
|
23492353
tk=<K_ON> { retval = tk.image; }
23502354
|

src/test/java/net/sf/jsqlparser/test/create/CreateTableTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ public void testCreateTableParams() throws JSQLParserException {
9999
public void testCreateTableUniqueConstraint() throws JSQLParserException {
100100
assertSqlCanBeParsedAndDeparsed("CREATE TABLE Activities (_id INTEGER PRIMARY KEY AUTOINCREMENT,uuid VARCHAR(255),user_id INTEGER,sound_id INTEGER,sound_type INTEGER,comment_id INTEGER,type String,tags VARCHAR(255),created_at INTEGER,content_id INTEGER,sharing_note_text VARCHAR(255),sharing_note_created_at INTEGER,UNIQUE (created_at, type, content_id, sound_id, user_id))", true);
101101
}
102+
103+
public void testCreateTableDefault() throws JSQLParserException {
104+
assertSqlCanBeParsedAndDeparsed("CREATE TABLE T1 (id integer default -1)");
105+
}
106+
107+
public void testCreateTableDefault2() throws JSQLParserException {
108+
assertSqlCanBeParsedAndDeparsed("CREATE TABLE T1 (id integer default 1)");
109+
}
102110

103111
public void testRUBiSCreateList() throws Exception {
104112
BufferedReader in = new BufferedReader(new InputStreamReader(CreateTableTest.class.getResourceAsStream("/RUBiS-create-requests.txt")));

0 commit comments

Comments
 (0)