Skip to content

Commit 6cd5481

Browse files
committed
fixes #273
1 parent 12b4a1e commit 6cd5481

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Also I would like to know about needed examples or documentation stuff.
4848

4949
## Extensions in the latest SNAPSHOT version 1.3
5050

51+
* support for special oracle type syntax **varchar2(255 BYTE)** (issue #273)
5152
* introduced dotted multipart names for uservariables (issue #608)
5253
* changed behaviour of dotted multipart names for tables and columns to accept ORM class names (issue #163)
5354
** the parser allows now empty inner names, to still accept missing schema names for SQLServer (db..col)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
155155
| <K_CAST:"CAST">
156156
| <K_CHARACTER:"CHARACTER">
157157
| <K_CHECK:"CHECK">
158+
| <K_CHAR:"CHAR">
158159
| <K_COLUMN:"COLUMN">
159160
| <K_COMMIT:"COMMIT">
160161
| <K_CONNECT:"CONNECT">
@@ -967,7 +968,7 @@ Not all names should be allowed for aliases.
967968
String RelObjectNameWithoutValue() :
968969
{ Token tk = null; }
969970
{
970-
(tk=<S_IDENTIFIER> | tk=<S_QUOTED_IDENTIFIER> | tk=<K_BYTE>
971+
(tk=<S_IDENTIFIER> | tk=<S_QUOTED_IDENTIFIER> | tk=<K_BYTE> | <K_CHAR>
971972
| tk=<K_CAST> | tk=<K_DO> | tk=<K_EXTRACT> | tk=<K_FIRST> | tk=<K_FOLLOWING>
972973
| tk=<K_LAST> | tk=<K_MATERIALIZED> | tk=<K_NULLS> | tk=<K_PARTITION> | tk=<K_RANGE>
973974
| tk=<K_ROW> | tk=<K_ROWS> | tk=<K_SIBLINGS> | tk=<K_XML>
@@ -3220,12 +3221,12 @@ ColDataType ColDataType():
32203221
(
32213222
(tk=<K_CHARACTER> | tk=<K_BIT>) [tk2=<K_VARYING>] { colDataType.setDataType(tk.image + (tk2!=null?" " + tk2.image:"")); }
32223223
| tk=<K_DOUBLE> [LOOKAHEAD(2) tk2=<K_PRECISION>] { colDataType.setDataType(tk.image + (tk2!=null?" " + tk2.image:"")); }
3223-
| ( tk=<S_IDENTIFIER> | tk=<K_DATETIMELITERAL> | tk=<K_XML> | tk=<K_INTERVAL> | tk=<DT_ZONE> )
3224+
| ( tk=<S_IDENTIFIER> | tk=<K_DATETIMELITERAL> | tk=<K_XML> | tk=<K_INTERVAL> | tk=<DT_ZONE> | tk=<K_CHAR> )
32243225
{ colDataType.setDataType(tk.image); }
32253226
| tk=<K_UNSIGNED> tk2=<S_IDENTIFIER> {colDataType.setDataType(tk.image + " " + tk2.image);}
32263227
)
32273228

3228-
[LOOKAHEAD(2) "(" {tk2 =null;} ( (tk=<S_LONG> [ tk2=<K_BYTE> ] | tk=<S_CHAR_LITERAL> | tk=<S_IDENTIFIER> )
3229+
[LOOKAHEAD(2) "(" {tk2 =null;} ( (tk=<S_LONG> [ tk2=<K_BYTE> | tk2=<K_CHAR> ] | tk=<S_CHAR_LITERAL> | tk=<S_IDENTIFIER> )
32293230
{ argumentsStringList.add(tk.image + (tk2!=null?" " + tk2.image:"")); } ["," {/*argumentsStringList.add(",");*/}] )* ")"]
32303231
[( "[" {tk=null;} [ tk=<S_LONG> ] { array.add(tk!=null?Integer.valueOf(tk.image):null); } "]" )+ { colDataType.setArrayData(array); } ]
32313232
[<K_CHARACTER> <K_SET> tk=<S_IDENTIFIER> { colDataType.setCharacterSet(tk.image); } ]

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ public void testKeySyntaxWithLengthColumnParameter() throws JSQLParserException
284284
public void testIssue273Varchar2Byte() throws JSQLParserException {
285285
assertSqlCanBeParsedAndDeparsed("CREATE TABLE IF NOT EXISTS \"TABLE_OK\" (\"SOME_FIELD\" VARCHAR2 (256 BYTE))");
286286
}
287+
288+
public void testIssue273Varchar2Char() throws JSQLParserException {
289+
assertSqlCanBeParsedAndDeparsed("CREATE TABLE IF NOT EXISTS \"TABLE_OK\" (\"SOME_FIELD\" VARCHAR2 (256 CHAR))");
290+
}
287291

288292
public void testRUBiSCreateList() throws Exception {
289293
BufferedReader in = new BufferedReader(new InputStreamReader(CreateTableTest.class.

0 commit comments

Comments
 (0)