mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
增强测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@984 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -236,11 +236,20 @@ public class OracleExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.DAY || lexer.token() == Token.YEAR) {
|
||||
lexer.mark();
|
||||
|
||||
String name = lexer.token().name;
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
lexer.reset();
|
||||
return expr;
|
||||
}
|
||||
|
||||
OracleIntervalExpr interval = new OracleIntervalExpr();
|
||||
interval.setValue(expr);
|
||||
OracleIntervalType type = OracleIntervalType.valueOf(lexer.token().name);
|
||||
OracleIntervalType type = OracleIntervalType.valueOf(name);
|
||||
interval.setType(type);
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -76,10 +76,39 @@ public class Lexer {
|
||||
|
||||
protected boolean skipComment = true;
|
||||
|
||||
private SavePoint savePoint = null;
|
||||
|
||||
public Lexer(String input){
|
||||
this(input, true);
|
||||
}
|
||||
|
||||
private static class SavePoint {
|
||||
|
||||
int bp;
|
||||
int sp;
|
||||
int np;
|
||||
char ch;
|
||||
Token token;
|
||||
}
|
||||
|
||||
public void mark() {
|
||||
SavePoint savePoint = new SavePoint();
|
||||
savePoint.bp = bp;
|
||||
savePoint.sp = sp;
|
||||
savePoint.np = np;
|
||||
savePoint.ch = ch;
|
||||
savePoint.token = token;
|
||||
this.savePoint = savePoint;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.bp = savePoint.bp;
|
||||
this.sp = savePoint.sp;
|
||||
this.np = savePoint.np;
|
||||
this.ch = savePoint.ch;
|
||||
this.token = savePoint.token;
|
||||
}
|
||||
|
||||
public Lexer(String input, boolean skipComment){
|
||||
this(input.toCharArray(), input.length(), skipComment);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SQLParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected final String as() throws ParserException {
|
||||
protected String as() throws ParserException {
|
||||
String alias = null;
|
||||
|
||||
if (lexer.token() == Token.AS) {
|
||||
@@ -65,6 +65,12 @@ public class SQLParser {
|
||||
return alias;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.YEAR || lexer.token() == Token.DAY) {
|
||||
alias = lexer.token.name();
|
||||
lexer.nextToken();
|
||||
return alias;
|
||||
}
|
||||
|
||||
switch (lexer.token()) {
|
||||
case KEY:
|
||||
alias = lexer.token().name();
|
||||
@@ -86,6 +92,9 @@ public class SQLParser {
|
||||
} else if (lexer.token() == Token.LITERAL_CHARS) {
|
||||
alias = "'" + lexer.stringVal() + "'";
|
||||
lexer.nextToken();
|
||||
} else if (lexer.token() == Token.YEAR || lexer.token() == Token.DAY) {
|
||||
alias = lexer.token.name();
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
switch (lexer.token()) {
|
||||
|
||||
Reference in New Issue
Block a user