Skip to content

Commit a23d30b

Browse files
committed
fixes #921
1 parent a3669da commit a23d30b

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Also I would like to know about needed examples or documentation stuff.
6969
* allow **ON** as a value in a set statement (`SET myvalue = ON`)
7070
* support for **ALTER TABLE ONLY mytable ... **
7171
* allow foreign key definition in alter statements without referenced columns specification
72+
* allow datatype **binary** for column definitions
7273

7374
## Extensions of JSqlParser releases
7475

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
options{
1212
IGNORE_CASE = true ;
1313
STATIC = false;
14-
DEBUG_PARSER = false;
14+
DEBUG_PARSER = true;
1515
DEBUG_LOOKAHEAD = false;
1616
DEBUG_TOKEN_MANAGER = false;
1717
CACHE_TOKENS = false;
@@ -3688,22 +3688,6 @@ CreateTable CreateTable():
36883688
("("
36893689
coldef = ColumnDefinition()
36903690

3691-
/*
3692-
colDataType = ColDataType()
3693-
{
3694-
columnSpecs = new ArrayList();
3695-
}
3696-
3697-
( parameter=CreateParameter() { columnSpecs.addAll(parameter); } )*
3698-
3699-
{
3700-
coldef = new ColumnDefinition();
3701-
coldef.setColumnName(columnName);
3702-
coldef.setColDataType(colDataType);
3703-
if (columnSpecs.size() > 0)
3704-
coldef.setColumnSpecStrings(columnSpecs);
3705-
columnDefinitions.add(coldef);
3706-
}*/
37073691
{ columnDefinitions.add(coldef); }
37083692

37093693
(
@@ -3862,7 +3846,8 @@ ColDataType ColDataType():
38623846
(
38633847
(tk=<K_CHARACTER> | tk=<K_BIT>) [tk2=<K_VARYING>] { colDataType.setDataType(tk.image + (tk2!=null?" " + tk2.image:"")); }
38643848
| tk=<K_DOUBLE> [LOOKAHEAD(2) tk2=<K_PRECISION>] { colDataType.setDataType(tk.image + (tk2!=null?" " + tk2.image:"")); }
3865-
| ( tk=<S_IDENTIFIER> | tk=<K_DATETIMELITERAL> | tk=<K_DATE_LITERAL> | tk=<K_XML> | tk=<K_INTERVAL> | tk=<DT_ZONE> | tk=<K_CHAR> | tk=<K_SET> )
3849+
| ( tk=<S_IDENTIFIER> | tk=<K_DATETIMELITERAL> | tk=<K_DATE_LITERAL> | tk=<K_XML> | tk=<K_INTERVAL>
3850+
| tk=<DT_ZONE> | tk=<K_CHAR> | tk=<K_SET> | tk=<K_BINARY> )
38663851
{ colDataType.setDataType(tk.image); }
38673852
| tk=<K_UNSIGNED> tk2=<S_IDENTIFIER> {colDataType.setDataType(tk.image + " " + tk2.image);}
38683853
| LOOKAHEAD(2) tk=<K_SIGNED> tk2=<S_IDENTIFIER> {colDataType.setDataType(tk.image + " " + tk2.image);}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,4 +569,20 @@ public void testSettingCharacterSetIssue829() throws JSQLParserException {
569569

570570
assertEquals("GBK", colName.getColDataType().getCharacterSet());
571571
}
572+
573+
// @Test
574+
// public void testCreateTableIssue924() throws JSQLParserException {
575+
// assertSqlCanBeParsedAndDeparsed("CREATE TABLE test_descending_indexes (c1 INT, c2 INT, INDEX idx1 (c1 ASC, c2 DESC))");
576+
// }
577+
//
578+
// @Test
579+
// public void testCreateTableIssue924_2() throws JSQLParserException {
580+
// assertSqlCanBeParsedAndDeparsed("CREATE TABLE test_descending_indexes (c1 INT, c2 INT, INDEX idx1 (c1 ASC, c2 ASC), INDEX idx2 (c1 ASC, c2 DESC), INDEX idx3 (c1 DESC, c2 ASC), INDEX idx4 (c1 DESC, c2 DESC))");
581+
// }
582+
583+
@Test
584+
public void testCreateTableIssue921() throws JSQLParserException {
585+
assertSqlCanBeParsedAndDeparsed("CREATE TABLE binary_test (c1 binary (10))");
586+
}
572587
}
588+

0 commit comments

Comments
 (0)