Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
5f07c26c
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f07c26c
编写于
3月 17, 2017
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor SQLParser
上级
d1ac3157
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
162 addition
and
125 deletion
+162
-125
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/dialect/oracle/parser/OracleParser.java
...arding/parser/sql/dialect/oracle/parser/OracleParser.java
+7
-3
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/dialect/oracle/parser/OracleSelectParser.java
.../parser/sql/dialect/oracle/parser/OracleSelectParser.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/Parser.java
...ngdang/ddframe/rdb/sharding/parser/sql/parser/Parser.java
+1
-0
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/SQLParser.java
...ang/ddframe/rdb/sharding/parser/sql/parser/SQLParser.java
+146
-114
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/insert/AbstractInsertParser.java
...arding/parser/sql/parser/insert/AbstractInsertParser.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/select/AbstractSelectParser.java
...arding/parser/sql/parser/select/AbstractSelectParser.java
+5
-5
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/update/AbstractUpdateParser.java
...arding/parser/sql/parser/update/AbstractUpdateParser.java
+1
-1
未找到文件。
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/dialect/oracle/parser/OracleParser.java
浏览文件 @
5f07c26c
...
...
@@ -44,14 +44,18 @@ public class OracleParser extends SQLParser {
}
@Override
public
OrderByContext
parseSelectOrderByItem
(
final
SQLContext
sqlContext
)
{
OrderByContext
result
=
super
.
parseSelectOrderByItem
(
sqlContext
);
protected
Optional
<
OrderByContext
>
parseSelectOrderByItem
(
final
SQLContext
sqlContext
)
{
Optional
<
OrderByContext
>
result
=
super
.
parseSelectOrderByItem
(
sqlContext
);
skipAfterOrderByItem
();
return
result
;
}
private
void
skipAfterOrderByItem
()
{
if
(
skipIfEqual
(
OracleKeyword
.
NULLS
))
{
getLexer
().
nextToken
();
if
(!
skipIfEqual
(
OracleKeyword
.
FIRST
,
OracleKeyword
.
LAST
))
{
throw
new
ParserUnsupportedException
(
getLexer
().
getCurrentToken
().
getType
());
}
}
return
result
;
}
}
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/dialect/oracle/parser/OracleSelectParser.java
浏览文件 @
5f07c26c
...
...
@@ -291,7 +291,7 @@ public class OracleSelectParser extends AbstractSelectParser {
getExprParser
().
accept
(
DefaultKeyword
.
UPDATE
);
if
(
getExprParser
().
skipIfEqual
(
OracleKeyword
.
OF
))
{
do
{
getExprParser
().
parseExpr
();
getExprParser
().
parseExpr
ession
();
}
while
(
getExprParser
().
skipIfEqual
(
Symbol
.
COMMA
));
}
if
(
getExprParser
().
equalAny
(
OracleKeyword
.
NOWAIT
,
OracleKeyword
.
WAIT
))
{
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/Parser.java
浏览文件 @
5f07c26c
...
...
@@ -43,6 +43,7 @@ public class Parser {
*
* @return 小括号内所有的词法标记
*/
// TODO 判断? 增加param index
public
final
String
skipParentheses
()
{
StringBuilder
result
=
new
StringBuilder
(
""
);
int
count
=
0
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/SQLParser.java
浏览文件 @
5f07c26c
...
...
@@ -76,6 +76,98 @@ public class SQLParser extends Parser {
this
.
parameters
=
parameters
;
}
/**
* 解析表达式.
*
* @param sqlContext SQL上下文
* @return 表达式
*/
public
final
SQLExpr
parseExpression
(
final
SQLContext
sqlContext
)
{
int
beginPosition
=
getLexer
().
getCurrentToken
().
getEndPosition
();
SQLExpr
result
=
parseExpression
();
if
(
result
instanceof
SQLPropertyExpr
)
{
setTableToken
(
sqlContext
,
beginPosition
,
(
SQLPropertyExpr
)
result
);
}
return
result
;
}
/**
* 解析表达式.
*
* @return 表达式
*/
public
final
SQLExpr
parseExpression
()
{
String
literals
=
getLexer
().
getCurrentToken
().
getLiterals
();
final
SQLExpr
expression
=
getExpression
(
literals
);
if
(
skipIfEqual
(
Literals
.
IDENTIFIER
))
{
if
(
skipIfEqual
(
Symbol
.
DOT
))
{
String
property
=
getLexer
().
getCurrentToken
().
getLiterals
();
getLexer
().
nextToken
();
return
skipIfCompositeExpression
()
?
new
SQLIgnoreExpr
()
:
new
SQLPropertyExpr
(
new
SQLIdentifierExpr
(
literals
),
property
);
}
if
(
equalAny
(
Symbol
.
LEFT_PAREN
))
{
skipParentheses
();
skipRestCompositeExpression
();
return
new
SQLIgnoreExpr
();
}
return
skipIfCompositeExpression
()
?
new
SQLIgnoreExpr
()
:
expression
;
}
getLexer
().
nextToken
();
return
skipIfCompositeExpression
()
?
new
SQLIgnoreExpr
()
:
expression
;
}
private
SQLExpr
getExpression
(
final
String
literals
)
{
if
(
equalAny
(
Symbol
.
QUESTION
))
{
parametersIndex
++;
return
new
SQLPlaceholderExpr
(
parametersIndex
-
1
,
parameters
.
get
(
parametersIndex
-
1
));
}
if
(
equalAny
(
Literals
.
CHARS
))
{
return
new
SQLCharExpr
(
literals
);
}
// TODO 考虑long的情况
if
(
equalAny
(
Literals
.
INT
))
{
return
new
SQLNumberExpr
(
Integer
.
parseInt
(
literals
));
}
if
(
equalAny
(
Literals
.
FLOAT
))
{
return
new
SQLNumberExpr
(
Double
.
parseDouble
(
literals
));
}
// TODO 考虑long的情况
if
(
equalAny
(
Literals
.
HEX
))
{
return
new
SQLNumberExpr
(
Integer
.
parseInt
(
literals
,
16
));
}
if
(
equalAny
(
Literals
.
IDENTIFIER
))
{
return
new
SQLIdentifierExpr
(
SQLUtil
.
getExactlyValue
(
literals
));
}
return
new
SQLIgnoreExpr
();
}
private
boolean
skipIfCompositeExpression
()
{
if
(
equalAny
(
Symbol
.
PLUS
,
Symbol
.
SUB
,
Symbol
.
STAR
,
Symbol
.
SLASH
,
Symbol
.
PERCENT
,
Symbol
.
AMP
,
Symbol
.
BAR
,
Symbol
.
DOUBLE_AMP
,
Symbol
.
DOUBLE_BAR
,
Symbol
.
CARET
,
Symbol
.
DOT
,
Symbol
.
LEFT_PAREN
))
{
skipParentheses
();
skipRestCompositeExpression
();
return
true
;
}
return
false
;
}
private
void
skipRestCompositeExpression
()
{
while
(
skipIfEqual
(
Symbol
.
PLUS
,
Symbol
.
SUB
,
Symbol
.
STAR
,
Symbol
.
SLASH
,
Symbol
.
PERCENT
,
Symbol
.
AMP
,
Symbol
.
BAR
,
Symbol
.
DOUBLE_AMP
,
Symbol
.
DOUBLE_BAR
,
Symbol
.
CARET
,
Symbol
.
DOT
))
{
if
(
equalAny
(
Symbol
.
QUESTION
))
{
parametersIndex
++;
}
getLexer
().
nextToken
();
skipParentheses
();
}
}
private
void
setTableToken
(
final
SQLContext
sqlContext
,
final
int
beginPosition
,
final
SQLPropertyExpr
propertyExpr
)
{
String
tableName
=
sqlContext
.
getTables
().
get
(
0
).
getName
();
String
owner
=
propertyExpr
.
getOwner
().
getName
();
if
(
tableName
.
equalsIgnoreCase
(
SQLUtil
.
getExactlyValue
(
owner
)))
{
sqlContext
.
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
-
owner
.
length
(),
owner
,
tableName
));
}
}
/**
* 解析别名.
*
...
...
@@ -99,49 +191,55 @@ public class SQLParser extends Parser {
return
Optional
.
absent
();
}
public
List
<
OrderByContext
>
parseOrderBy
(
final
SQLContext
sqlContext
)
{
/**
* 解析排序.
*
* @param sqlContext SQL上下文
* @return 排序上下文
*/
public
final
List
<
OrderByContext
>
parseOrderBy
(
final
SQLContext
sqlContext
)
{
if
(!
skipIfEqual
(
DefaultKeyword
.
ORDER
))
{
return
Collections
.
emptyList
();
}
List
<
OrderByContext
>
result
=
new
LinkedList
<>();
skipIfEqual
(
DefaultKeyword
.
SIBLINGS
);
accept
(
DefaultKeyword
.
BY
);
OrderByContext
orderByContext
=
parseSelectOrderByItem
(
sqlContext
);
if
(
null
!=
orderByContext
)
{
result
.
add
(
orderByContext
);
}
while
(
equalAny
(
Symbol
.
COMMA
))
{
getLexer
().
nextToken
();
orderByContext
=
parseSelectOrderByItem
(
sqlContext
);
if
(
null
!=
orderByContext
)
{
result
.
add
(
orderByContext
);
do
{
Optional
<
OrderByContext
>
orderByContext
=
parseSelectOrderByItem
(
sqlContext
);
if
(
orderByContext
.
isPresent
())
{
result
.
add
(
orderByContext
.
get
());
}
}
while
(
skipIfEqual
(
Symbol
.
COMMA
));
return
result
;
}
p
ublic
OrderByContext
parseSelectOrderByItem
(
final
SQLContext
sqlContext
)
{
SQLExpr
expr
=
parseExpr
(
sqlContext
);
p
rotected
Optional
<
OrderByContext
>
parseSelectOrderByItem
(
final
SQLContext
sqlContext
)
{
SQLExpr
expr
=
parseExpr
ession
(
sqlContext
);
OrderByColumn
.
OrderByType
orderByType
=
OrderByColumn
.
OrderByType
.
ASC
;
if
(
equalAny
(
DefaultKeyword
.
ASC
))
{
getLexer
().
nextToken
();
}
else
if
(
equalAny
(
DefaultKeyword
.
DESC
))
{
getLexer
().
nextToken
();
if
(
skipIfEqual
(
DefaultKeyword
.
ASC
))
{
orderByType
=
OrderByColumn
.
OrderByType
.
ASC
;
}
else
if
(
skipIfEqual
(
DefaultKeyword
.
DESC
))
{
orderByType
=
OrderByColumn
.
OrderByType
.
DESC
;
}
if
(
expr
instanceof
SQLNumberExpr
)
{
return
new
OrderByContext
(((
SQLNumberExpr
)
expr
).
getNumber
().
intValue
(),
orderByType
);
return
Optional
.
of
(
new
OrderByContext
(((
SQLNumberExpr
)
expr
).
getNumber
().
intValue
(),
orderByType
)
);
}
if
(
expr
instanceof
SQLIdentifierExpr
)
{
return
new
OrderByContext
(
SQLUtil
.
getExactlyValue
(((
SQLIdentifierExpr
)
expr
).
getName
()),
orderByType
);
return
Optional
.
of
(
new
OrderByContext
(
SQLUtil
.
getExactlyValue
(((
SQLIdentifierExpr
)
expr
).
getName
()),
orderByType
)
);
}
if
(
expr
instanceof
SQLPropertyExpr
)
{
SQLPropertyExpr
sqlPropertyExpr
=
(
SQLPropertyExpr
)
expr
;
return
new
OrderByContext
(
SQLUtil
.
getExactlyValue
(
sqlPropertyExpr
.
getOwner
().
getName
()),
SQLUtil
.
getExactlyValue
(
sqlPropertyExpr
.
getName
()),
orderByType
);
return
Optional
.
of
(
new
OrderByContext
(
SQLUtil
.
getExactlyValue
(
sqlPropertyExpr
.
getOwner
().
getName
()),
SQLUtil
.
getExactlyValue
(
sqlPropertyExpr
.
getName
()),
orderByType
)
);
}
return
null
;
return
Optional
.
absent
()
;
}
/**
* 解析单表.
*
* @param sqlContext SQL上下文
*/
public
final
void
parseSingleTable
(
final
SQLContext
sqlContext
)
{
boolean
hasParentheses
=
false
;
if
(
skipIfEqual
(
Symbol
.
LEFT_PAREN
))
{
...
...
@@ -167,14 +265,19 @@ public class SQLParser extends Parser {
}
tableContext
=
new
TableContext
(
literals
,
SQLUtil
.
getExactlyValue
(
literals
),
parseAlias
());
}
if
(
is
Join
())
{
if
(
skip
Join
())
{
throw
new
UnsupportedOperationException
(
"Cannot support Multiple-Table."
);
}
sqlContext
.
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
,
tableContext
.
getOriginalLiterals
(),
tableContext
.
getName
()));
sqlContext
.
getTables
().
add
(
tableContext
);
}
public
final
boolean
isJoin
()
{
/**
* 跳过表关联.
*
* @return 是否表关联.
*/
public
final
boolean
skipJoin
()
{
if
(
skipIfEqual
(
DefaultKeyword
.
LEFT
,
DefaultKeyword
.
RIGHT
,
DefaultKeyword
.
FULL
))
{
skipIfEqual
(
DefaultKeyword
.
OUTER
);
accept
(
DefaultKeyword
.
JOIN
);
...
...
@@ -196,6 +299,13 @@ public class SQLParser extends Parser {
return
false
;
}
/**
* 解析查询列.
*
* @param index 参数索引
* @param sqlContext SQL上下文
* @return 查询列上下文
*/
public
final
SelectItemContext
parseSelectItem
(
final
int
index
,
final
SelectSQLContext
sqlContext
)
{
skipIfEqual
(
DefaultKeyword
.
CONNECT_BY_ROOT
);
String
literals
=
getLexer
().
getCurrentToken
().
getLiterals
();
...
...
@@ -221,7 +331,13 @@ public class SQLParser extends Parser {
return
new
CommonSelectItemContext
(
SQLUtil
.
getExactlyValue
(
expression
.
toString
()),
parseAlias
(),
index
,
false
);
}
public
Optional
<
ConditionContext
>
parseWhere
(
final
SQLContext
sqlContext
)
{
/**
* 解析查询条件.
*
* @param sqlContext SQL上下文
* @return 条件上下文
*/
public
final
Optional
<
ConditionContext
>
parseWhere
(
final
SQLContext
sqlContext
)
{
if
(
skipIfEqual
(
DefaultKeyword
.
WHERE
))
{
ParseContext
parseContext
=
getParseContext
(
sqlContext
);
parseConditions
(
sqlContext
,
parseContext
);
...
...
@@ -249,9 +365,9 @@ public class SQLParser extends Parser {
}
// TODO 解析组合expr
public
void
parseComparisonCondition
(
final
SQLContext
sqlContext
,
final
ParseContext
parseContext
)
{
public
final
void
parseComparisonCondition
(
final
SQLContext
sqlContext
,
final
ParseContext
parseContext
)
{
skipIfEqual
(
Symbol
.
LEFT_PAREN
);
SQLExpr
left
=
parseExpr
(
sqlContext
);
SQLExpr
left
=
parseExpr
ession
(
sqlContext
);
if
(
equalAny
(
Symbol
.
EQ
))
{
parseEqualCondition
(
sqlContext
,
parseContext
,
left
);
}
else
if
(
equalAny
(
DefaultKeyword
.
IN
))
{
...
...
@@ -267,7 +383,7 @@ public class SQLParser extends Parser {
private
void
parseEqualCondition
(
final
SQLContext
sqlContext
,
final
ParseContext
parseContext
,
final
SQLExpr
left
)
{
getLexer
().
nextToken
();
SQLExpr
right
=
parseExpr
(
sqlContext
);
SQLExpr
right
=
parseExpr
ession
(
sqlContext
);
// TODO 如果有多表,且找不到column是哪个表的,则不加入condition,以后需要解析binding table
if
((
1
==
sqlContext
.
getTables
().
size
()
||
left
instanceof
SQLPropertyExpr
)
&&
(
right
instanceof
SQLLiteralExpr
||
right
instanceof
SQLPlaceholderExpr
))
{
parseContext
.
addCondition
(
left
,
Condition
.
BinaryOperator
.
EQUAL
,
Collections
.
singletonList
(
right
));
...
...
@@ -282,7 +398,7 @@ public class SQLParser extends Parser {
if
(
equalAny
(
Symbol
.
COMMA
))
{
getLexer
().
nextToken
();
}
rights
.
add
(
parseExpr
(
sqlContext
));
rights
.
add
(
parseExpr
ession
(
sqlContext
));
}
while
(!
equalAny
(
Symbol
.
RIGHT_PAREN
));
parseContext
.
addCondition
(
left
,
Condition
.
BinaryOperator
.
IN
,
rights
);
getLexer
().
nextToken
();
...
...
@@ -291,98 +407,14 @@ public class SQLParser extends Parser {
private
void
parseBetweenCondition
(
final
SQLContext
sqlContext
,
final
ParseContext
parseContext
,
final
SQLExpr
left
)
{
getLexer
().
nextToken
();
List
<
SQLExpr
>
rights
=
new
LinkedList
<>();
rights
.
add
(
parseExpr
(
sqlContext
));
rights
.
add
(
parseExpr
ession
(
sqlContext
));
accept
(
DefaultKeyword
.
AND
);
rights
.
add
(
parseExpr
(
sqlContext
));
rights
.
add
(
parseExpr
ession
(
sqlContext
));
parseContext
.
addCondition
(
left
,
Condition
.
BinaryOperator
.
BETWEEN
,
rights
);
}
private
void
parserOtherCondition
(
final
SQLContext
sqlContext
)
{
getLexer
().
nextToken
();
parseExpr
(
sqlContext
);
}
public
SQLExpr
parseExpr
(
final
SQLContext
sqlContext
)
{
int
beginPosition
=
getLexer
().
getCurrentToken
().
getEndPosition
();
SQLExpr
result
=
parseExpr
();
if
(
result
instanceof
SQLPropertyExpr
)
{
String
tableName
=
sqlContext
.
getTables
().
get
(
0
).
getName
();
String
owner
=
(((
SQLPropertyExpr
)
result
).
getOwner
()).
getName
();
if
(
tableName
.
equalsIgnoreCase
(
SQLUtil
.
getExactlyValue
(
owner
)))
{
sqlContext
.
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
-
owner
.
length
(),
owner
,
tableName
));
}
}
return
result
;
}
public
SQLExpr
parseExpr
()
{
String
literals
=
getLexer
().
getCurrentToken
().
getLiterals
();
if
(
equalAny
(
Literals
.
IDENTIFIER
))
{
SQLExpr
result
=
getSQLExpr
(
SQLUtil
.
getExactlyValue
(
literals
));
getLexer
().
nextToken
();
if
(
skipIfEqual
(
Symbol
.
DOT
))
{
String
property
=
getLexer
().
getCurrentToken
().
getLiterals
();
getLexer
().
nextToken
();
if
(!
equalAny
(
Symbol
.
PLUS
,
Symbol
.
SUB
,
Symbol
.
STAR
,
Symbol
.
SLASH
))
{
return
new
SQLPropertyExpr
(
new
SQLIdentifierExpr
(
literals
),
property
);
}
skipRest
();
return
new
SQLIgnoreExpr
();
}
if
(
equalAny
(
Symbol
.
LEFT_PAREN
))
{
skipParentheses
();
skipRest
();
return
new
SQLIgnoreExpr
();
}
if
(!
equalAny
(
Symbol
.
PLUS
,
Symbol
.
SUB
,
Symbol
.
STAR
,
Symbol
.
SLASH
))
{
return
result
;
}
skipRest
();
return
new
SQLIgnoreExpr
();
}
SQLExpr
result
=
getSQLExpr
(
literals
);
getLexer
().
nextToken
();
if
(!
equalAny
(
Symbol
.
PLUS
,
Symbol
.
SUB
,
Symbol
.
STAR
,
Symbol
.
SLASH
))
{
return
result
;
}
skipParentheses
();
skipRest
();
return
new
SQLIgnoreExpr
();
}
private
void
skipRest
()
{
while
(
skipIfEqual
(
Symbol
.
PLUS
,
Symbol
.
SUB
,
Symbol
.
STAR
,
Symbol
.
SLASH
))
{
if
(
equalAny
(
Symbol
.
QUESTION
))
{
++
parametersIndex
;
}
getLexer
().
nextToken
();
if
(
skipIfEqual
(
Symbol
.
DOT
))
{
getLexer
().
nextToken
();
}
skipParentheses
();
}
}
private
SQLExpr
getSQLExpr
(
final
String
literals
)
{
if
(
equalAny
(
Symbol
.
QUESTION
))
{
parametersIndex
++;
return
new
SQLPlaceholderExpr
(
parametersIndex
-
1
,
parameters
.
get
(
parametersIndex
-
1
));
}
if
(
equalAny
(
Literals
.
CHARS
))
{
return
new
SQLCharExpr
(
literals
);
}
if
(
equalAny
(
Literals
.
INT
))
{
return
new
SQLNumberExpr
(
Integer
.
parseInt
(
literals
));
}
if
(
equalAny
(
Literals
.
FLOAT
))
{
return
new
SQLNumberExpr
(
Double
.
parseDouble
(
literals
));
}
if
(
equalAny
(
Literals
.
HEX
))
{
return
new
SQLNumberExpr
(
Integer
.
parseInt
(
literals
,
16
));
}
if
(
equalAny
(
Literals
.
IDENTIFIER
))
{
return
new
SQLIdentifierExpr
(
literals
);
}
return
new
SQLIgnoreExpr
();
parseExpression
(
sqlContext
);
}
}
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/insert/AbstractInsertParser.java
浏览文件 @
5f07c26c
...
...
@@ -158,7 +158,7 @@ public abstract class AbstractInsertParser {
exprParser
.
accept
(
Symbol
.
LEFT_PAREN
);
List
<
SQLExpr
>
sqlExprs
=
new
LinkedList
<>();
do
{
sqlExprs
.
add
(
exprParser
.
parseExpr
());
sqlExprs
.
add
(
exprParser
.
parseExpr
ession
());
}
while
(
exprParser
.
skipIfEqual
(
Symbol
.
COMMA
));
ItemsToken
itemsToken
=
new
ItemsToken
(
exprParser
.
getLexer
().
getCurrentToken
().
getEndPosition
()
-
exprParser
.
getLexer
().
getCurrentToken
().
getLiterals
().
length
());
int
count
=
0
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/select/AbstractSelectParser.java
浏览文件 @
5f07c26c
...
...
@@ -131,7 +131,7 @@ public abstract class AbstractSelectParser {
if
(
getExprParser
().
skipIfEqual
(
DefaultKeyword
.
GROUP
))
{
getExprParser
().
accept
(
DefaultKeyword
.
BY
);
while
(
true
)
{
addGroupByItem
(
exprParser
.
parseExpr
(
sqlContext
));
addGroupByItem
(
exprParser
.
parseExpr
ession
(
sqlContext
));
if
(!
getExprParser
().
equalAny
(
Symbol
.
COMMA
))
{
break
;
}
...
...
@@ -141,10 +141,10 @@ public abstract class AbstractSelectParser {
getExprParser
().
getLexer
().
nextToken
();
}
if
(
getExprParser
().
skipIfEqual
(
DefaultKeyword
.
HAVING
))
{
exprParser
.
parseExpr
(
sqlContext
);
exprParser
.
parseExpr
ession
(
sqlContext
);
}
}
else
if
(
getExprParser
().
skipIfEqual
(
DefaultKeyword
.
HAVING
))
{
exprParser
.
parseExpr
(
sqlContext
);
exprParser
.
parseExpr
ession
(
sqlContext
);
}
}
...
...
@@ -194,7 +194,7 @@ public abstract class AbstractSelectParser {
}
protected
void
parseJoinTable
()
{
if
(
getExprParser
().
is
Join
())
{
if
(
getExprParser
().
skip
Join
())
{
parseTable
();
if
(
getExprParser
().
skipIfEqual
(
DefaultKeyword
.
ON
))
{
do
{
...
...
@@ -210,7 +210,7 @@ public abstract class AbstractSelectParser {
}
private
void
parseTableCondition
(
final
int
startPosition
)
{
SQLExpr
sqlExpr
=
exprParser
.
parseExpr
();
SQLExpr
sqlExpr
=
exprParser
.
parseExpr
ession
();
if
(
sqlExpr
instanceof
SQLPropertyExpr
)
{
SQLPropertyExpr
sqlPropertyExpr
=
(
SQLPropertyExpr
)
sqlExpr
;
for
(
TableContext
each
:
sqlContext
.
getTables
())
{
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/sql/parser/update/AbstractUpdateParser.java
浏览文件 @
5f07c26c
...
...
@@ -91,7 +91,7 @@ public abstract class AbstractUpdateParser {
}
}
exprParser
.
skipIfEqual
(
Symbol
.
EQ
,
Symbol
.
COLON_EQ
);
exprParser
.
parseExpr
(
sqlContext
);
exprParser
.
parseExpr
ession
(
sqlContext
);
parametersIndex
=
exprParser
.
getParametersIndex
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录