Skip to content

Commit aa8e15a

Browse files
committed
additional letters token rule included, to expand range of acceptable identifiers
1 parent 50a56b0 commit aa8e15a

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

change.log

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,7 @@ Added connect visitor
161161
TableNamesFinder included in source
162162
Added proper support for sets (union, intersect)
163163
Added support for extract(year from datetime-expr)
164-
Start implementation of analytical expressions
164+
Start implementation of analytical expressions
165+
166+
0.8.1-SNAPSHOT
167+
Expansionpoint for additional letters included

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>net.sf.jsqlparser</groupId>
55
<artifactId>jsqlparser</artifactId>
6-
<version>0.8.0-SNAPSHOT</version>
6+
<version>0.8.1-SNAPSHOT</version>
77
<name>clone of the jsqlparser library</name>
88
<dependencies>
99
<dependency>

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ options{
2626
// DEBUG_LOOKAHEAD= true ;
2727
// FORCE_LA_CHECK=true;
2828
// DEBUG_TOKEN_MANAGER=true;
29+
// UNICODE_INPUT=true;
2930
}
3031

3132
PARSER_BEGIN(CCJSqlParser)
@@ -253,11 +254,21 @@ SPECIAL_TOKEN:
253254

254255
TOKEN:
255256
{
256-
< S_IDENTIFIER: ( <LETTER> )+ ( <DIGIT> | <LETTER> |<SPECIAL_CHARS>)* >
257+
< S_IDENTIFIER: ( <LETTER> | <ADDITIONAL_LETTERS> )+ ( <DIGIT> | <LETTER> | <ADDITIONAL_LETTERS> | <SPECIAL_CHARS>)* >
257258
| < #LETTER: ["a"-"z", "A"-"Z", "_"] >
258259
| < #SPECIAL_CHARS: "$" | "_">
259260
| < S_CHAR_LITERAL: "'" (~["'"])* "'" ("'" (~["'"])* "'")*>
260261
| < S_QUOTED_IDENTIFIER: "\"" (~["\n","\r","\""])* "\"" | ("`" (~["\n","\r","`"])* "`") | ("[" (~["\n","\r","]"])* "]") >
262+
263+
/*
264+
To deal with database names (columns, tables) using not only latin base characters, one
265+
can expand the following rule to accept additional letters. Here is the
266+
addition of german umlauts.
267+
268+
There seems to be no way to recognize letters by an external function to allow
269+
a configurable addition. One must rebuild JSqlParser with this new "Letterset".
270+
*/
271+
| < #ADDITIONAL_LETTERS: ["�","�","�","�","�","�","�"] >
261272
}
262273

263274

src/test/java/net/sf/jsqlparser/test/select/SelectTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,17 @@ public void testProblemFunction2() throws JSQLParserException {
737737
String stmt = "SELECT sysdate FROM testtable";
738738
assertSqlCanBeParsedAndDeparsed(stmt);
739739
}
740+
741+
public void testAdditionalLettersGerman() throws JSQLParserException {
742+
String stmt = "SELECT colä, colü, colö FROM testtableöäü";
743+
assertSqlCanBeParsedAndDeparsed(stmt);
744+
745+
stmt = "SELECT colÄ, colÜ, colÖ FROM testtableÖÜÄ";
746+
assertSqlCanBeParsedAndDeparsed(stmt);
747+
748+
stmt = "SELECT Äcol FROM testtableÖÜÄ";
749+
assertSqlCanBeParsedAndDeparsed(stmt);
750+
}
740751

741752
private void assertSqlCanBeParsedAndDeparsed(String statement) throws JSQLParserException {
742753
Statement parsed = parserManager.parse(new StringReader(statement));

0 commit comments

Comments
 (0)