Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
773e9dea
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,发现更多精彩内容 >>
提交
773e9dea
编写于
5月 11, 2017
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
extract token package
上级
edee3928
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
89 addition
and
33 deletion
+89
-33
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/SQLParser.java
...ngdang/ddframe/rdb/sharding/parsing/parser/SQLParser.java
+5
-6
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/dialect/mysql/MySQLParser.java
...db/sharding/parsing/parser/dialect/mysql/MySQLParser.java
+2
-2
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/statement/select/AbstractSelectParser.java
...parsing/parser/statement/select/AbstractSelectParser.java
+4
-5
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/statement/update/AbstractUpdateParser.java
...parsing/parser/statement/update/AbstractUpdateParser.java
+3
-4
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/token/ItemsToken.java
...ddframe/rdb/sharding/parsing/parser/token/ItemsToken.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/token/OffsetLimitToken.java
...e/rdb/sharding/parsing/parser/token/OffsetLimitToken.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/token/RowCountLimitToken.java
...rdb/sharding/parsing/parser/token/RowCountLimitToken.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/token/SQLToken.java
...g/ddframe/rdb/sharding/parsing/parser/token/SQLToken.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/token/TableToken.java
...ddframe/rdb/sharding/parsing/parser/token/TableToken.java
+10
-2
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/rewrite/SQLBuilderContext.java
...gdang/ddframe/rdb/sharding/rewrite/SQLBuilderContext.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/rewrite/SQLRewriteEngine.java
...ngdang/ddframe/rdb/sharding/rewrite/SQLRewriteEngine.java
+5
-5
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/router/SQLRouteEngine.java
.../dangdang/ddframe/rdb/sharding/router/SQLRouteEngine.java
+55
-4
未找到文件。
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/SQLParser.java
浏览文件 @
773e9dea
...
...
@@ -26,7 +26,7 @@ import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SQLContext;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SelectItemContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.ShardingColumnContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.TableContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.TableToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.TableToken
;
import
com.dangdang.ddframe.rdb.sharding.constant.AggregationType
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.exception.SQLParsingUnsupportedException
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.expr.SQLTextExpr
;
...
...
@@ -155,10 +155,9 @@ public class SQLParser extends AbstractParser {
}
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
)))
{
sqlBuilderContext
.
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
-
owner
.
length
(),
owner
,
tableName
));
if
(
sqlContext
.
getTables
().
get
(
0
).
getName
()
.
equalsIgnoreCase
(
SQLUtil
.
getExactlyValue
(
owner
)))
{
sqlBuilderContext
.
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
-
owner
.
length
(),
owner
));
}
}
...
...
@@ -218,7 +217,7 @@ public class SQLParser extends AbstractParser {
if
(
skipJoin
())
{
throw
new
UnsupportedOperationException
(
"Cannot support Multiple-Table."
);
}
sqlBuilderContext
.
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
,
tableContext
.
getOriginalLiterals
()
,
tableContext
.
getName
()
));
sqlBuilderContext
.
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
,
tableContext
.
getOriginalLiterals
()));
sqlContext
.
getTables
().
add
(
tableContext
);
sqlContext
.
getSqlBuilderContext
().
getTableNames
().
add
(
tableContext
.
getName
());
}
...
...
@@ -275,7 +274,7 @@ public class SQLParser extends AbstractParser {
expression
.
append
(
value
);
getLexer
().
nextToken
();
if
(
equalAny
(
Symbol
.
DOT
))
{
sqlBuilderContext
.
getSqlTokens
().
add
(
new
TableToken
(
position
,
value
,
SQLUtil
.
getExactlyValue
(
value
)
));
sqlBuilderContext
.
getSqlTokens
().
add
(
new
TableToken
(
position
,
value
));
}
}
return
new
CommonSelectItemContext
(
SQLUtil
.
getExactlyValue
(
expression
.
toString
()),
parseAlias
(),
false
);
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/dialect/mysql/MySQLParser.java
浏览文件 @
773e9dea
...
...
@@ -24,8 +24,8 @@ import com.dangdang.ddframe.rdb.sharding.parsing.lexer.token.Literals;
import
com.dangdang.ddframe.rdb.sharding.parsing.lexer.token.Symbol
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.SQLParser
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.LimitContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.OffsetLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.RowCountLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.OffsetLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.RowCountLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.exception.SQLParsingException
;
/**
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/statement/select/AbstractSelectParser.java
浏览文件 @
773e9dea
...
...
@@ -21,13 +21,13 @@ import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.AggregationSelec
import
com.dangdang.ddframe.rdb.sharding.constant.AggregationType
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.CommonSelectItemContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.GroupByContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.ItemsToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.ItemsToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.OrderByContext
;
import
com.dangdang.ddframe.rdb.sharding.constant.OrderType
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SelectItemContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SelectSQLContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.TableContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.TableToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.TableToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.expr.SQLExpr
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.expr.SQLIdentifierExpr
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.expr.SQLNumberExpr
;
...
...
@@ -315,7 +315,7 @@ public abstract class AbstractSelectParser implements SQLStatementParser {
return
;
}
// FIXME 根据shardingRule过滤table
sqlParser
.
getSqlBuilderContext
().
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
,
literals
,
SQLUtil
.
getExactlyValue
(
literals
)
));
sqlParser
.
getSqlBuilderContext
().
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
,
literals
));
sqlContext
.
getTables
().
add
(
new
TableContext
(
literals
,
SQLUtil
.
getExactlyValue
(
literals
),
getSqlParser
().
parseAlias
()));
sqlContext
.
getSqlBuilderContext
().
getTableNames
().
add
(
SQLUtil
.
getExactlyValue
(
literals
));
}
...
...
@@ -344,8 +344,7 @@ public abstract class AbstractSelectParser implements SQLStatementParser {
SQLPropertyExpr
sqlPropertyExpr
=
(
SQLPropertyExpr
)
sqlExpr
;
for
(
TableContext
each
:
sqlContext
.
getTables
())
{
if
(
each
.
getName
().
equalsIgnoreCase
(
SQLUtil
.
getExactlyValue
(
sqlPropertyExpr
.
getOwner
().
getName
())))
{
sqlParser
.
getSqlBuilderContext
().
getSqlTokens
().
add
(
new
TableToken
(
startPosition
,
sqlPropertyExpr
.
getOwner
().
getName
(),
SQLUtil
.
getExactlyValue
(
sqlPropertyExpr
.
getOwner
().
getName
())));
sqlParser
.
getSqlBuilderContext
().
getSqlTokens
().
add
(
new
TableToken
(
startPosition
,
sqlPropertyExpr
.
getOwner
().
getName
()));
}
}
}
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/statement/update/AbstractUpdateParser.java
浏览文件 @
773e9dea
...
...
@@ -20,7 +20,7 @@ package com.dangdang.ddframe.rdb.sharding.parsing.parser.statement.update;
import
com.dangdang.ddframe.rdb.sharding.parsing.lexer.token.DefaultKeyword
;
import
com.dangdang.ddframe.rdb.sharding.parsing.lexer.token.Symbol
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.SQLParser
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.TableToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.TableToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.UpdateSQLContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.statement.SQLStatementParser
;
import
com.dangdang.ddframe.rdb.sharding.util.SQLUtil
;
...
...
@@ -75,10 +75,9 @@ public abstract class AbstractUpdateParser implements SQLStatementParser {
int
beginPosition
=
sqlParser
.
getLexer
().
getCurrentToken
().
getEndPosition
();
String
literals
=
sqlParser
.
getLexer
().
getCurrentToken
().
getLiterals
();
sqlParser
.
getLexer
().
nextToken
();
String
tableName
=
sqlContext
.
getTables
().
get
(
0
).
getName
();
if
(
sqlParser
.
skipIfEqual
(
Symbol
.
DOT
))
{
if
(
tableName
.
equalsIgnoreCase
(
SQLUtil
.
getExactlyValue
(
literals
)))
{
sqlParser
.
getSqlBuilderContext
().
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
-
literals
.
length
(),
literals
,
tableName
));
if
(
sqlContext
.
getTables
().
get
(
0
).
getName
()
.
equalsIgnoreCase
(
SQLUtil
.
getExactlyValue
(
literals
)))
{
sqlParser
.
getSqlBuilderContext
().
getSqlTokens
().
add
(
new
TableToken
(
beginPosition
-
literals
.
length
(),
literals
));
}
sqlParser
.
getLexer
().
nextToken
();
}
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
context
/ItemsToken.java
→
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
token
/ItemsToken.java
浏览文件 @
773e9dea
...
...
@@ -15,7 +15,7 @@
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
;
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
context
/OffsetLimitToken.java
→
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
token
/OffsetLimitToken.java
浏览文件 @
773e9dea
...
...
@@ -15,7 +15,7 @@
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
;
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
context
/RowCountLimitToken.java
→
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
token
/RowCountLimitToken.java
浏览文件 @
773e9dea
...
...
@@ -15,7 +15,7 @@
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
;
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
context
/SQLToken.java
→
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
token
/SQLToken.java
浏览文件 @
773e9dea
...
...
@@ -15,7 +15,7 @@
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
;
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
;
/**
* SQL语言标记对象.
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
context
/TableToken.java
→
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/
token
/TableToken.java
浏览文件 @
773e9dea
...
...
@@ -15,8 +15,9 @@
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
;
package
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
;
import
com.dangdang.ddframe.rdb.sharding.util.SQLUtil
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -33,5 +34,12 @@ public final class TableToken implements SQLToken {
private
final
String
originalLiterals
;
private
final
String
tableName
;
/**
* 获取表名称.
*
* @return 表名称
*/
public
String
getTableName
()
{
return
SQLUtil
.
getExactlyValue
(
originalLiterals
);
}
}
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/rewrite/SQLBuilderContext.java
浏览文件 @
773e9dea
package
com.dangdang.ddframe.rdb.sharding.rewrite
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.SQLToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.SQLToken
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/rewrite/SQLRewriteEngine.java
浏览文件 @
773e9dea
...
...
@@ -17,11 +17,11 @@
package
com.dangdang.ddframe.rdb.sharding.rewrite
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.ItemsToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.OffsetLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.RowCountLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.SQLToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.TableToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.ItemsToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.OffsetLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.RowCountLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.SQLToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.TableToken
;
import
lombok.RequiredArgsConstructor
;
import
java.util.Collections
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/router/SQLRouteEngine.java
浏览文件 @
773e9dea
...
...
@@ -26,15 +26,18 @@ import com.dangdang.ddframe.rdb.sharding.parsing.SQLParsingEngine;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.ConditionContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.DeleteSQLContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.InsertSQLContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.token.ItemsToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.LimitContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.OffsetLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
context
.RowCountLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.OffsetLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.
token
.RowCountLimitToken
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SQLContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SelectSQLContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.ShardingColumnContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.TableContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.UpdateSQLContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.exception.SQLParsingException
;
import
com.dangdang.ddframe.rdb.sharding.rewrite.GenerateKeysUtils
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.expr.SQLNumberExpr
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.expr.SQLPlaceholderExpr
;
import
com.dangdang.ddframe.rdb.sharding.rewrite.SQLBuilder
;
import
com.dangdang.ddframe.rdb.sharding.rewrite.SQLBuilderContext
;
import
com.dangdang.ddframe.rdb.sharding.rewrite.SQLRewriteEngine
;
...
...
@@ -49,6 +52,7 @@ import com.google.common.collect.Sets;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -96,12 +100,59 @@ public final class SQLRouteEngine {
log
.
debug
(
"Logic SQL: {}, {}"
,
logicSql
,
parameters
);
SQLContext
result
=
new
SQLParsingEngine
(
databaseType
,
logicSql
,
shardingRule
).
parseStatement
();
MetricsContext
.
stop
(
context
);
// TODO 提炼至rewrite模块
if
(
result
instanceof
InsertSQLContext
)
{
GenerateKeysUtils
.
appendGenerateKeys
(
shardingRule
,
parameters
,
(
InsertSQLContext
)
result
);
String
tableName
=
result
.
getTables
().
get
(
0
).
getName
();
ItemsToken
columnsToken
=
new
ItemsToken
(((
InsertSQLContext
)
result
).
getColumnsListLastPosition
());
Collection
<
String
>
autoIncrementColumns
=
shardingRule
.
getAutoIncrementColumns
(
tableName
);
for
(
String
each
:
autoIncrementColumns
)
{
if
(!
isIncluded
((
InsertSQLContext
)
result
,
each
))
{
columnsToken
.
getItems
().
add
(
each
);
}
}
if
(!
columnsToken
.
getItems
().
isEmpty
())
{
result
.
getSqlBuilderContext
().
getSqlTokens
().
add
(
columnsToken
);
}
ItemsToken
valuesToken
=
new
ItemsToken
(((
InsertSQLContext
)
result
).
getValuesListLastPosition
());
int
offset
=
parameters
.
size
()
-
1
;
for
(
String
each
:
autoIncrementColumns
)
{
if
(
isIncluded
((
InsertSQLContext
)
result
,
each
))
{
continue
;
}
Number
generatedId
=
shardingRule
.
findTableRule
(
tableName
).
generateId
(
each
);
ShardingColumnContext
shardingColumnContext
=
new
ShardingColumnContext
(
each
,
tableName
,
true
);
if
(
parameters
.
isEmpty
())
{
valuesToken
.
getItems
().
add
(
generatedId
.
toString
());
if
(
shardingRule
.
isShardingColumn
(
shardingColumnContext
))
{
result
.
getConditionContext
().
add
(
new
ConditionContext
.
Condition
(
shardingColumnContext
,
new
SQLNumberExpr
(
generatedId
)));
}
}
else
{
valuesToken
.
getItems
().
add
(
"?"
);
parameters
.
add
(
generatedId
);
offset
++;
if
(
shardingRule
.
isShardingColumn
(
shardingColumnContext
))
{
result
.
getConditionContext
().
add
(
new
ConditionContext
.
Condition
(
shardingColumnContext
,
new
SQLPlaceholderExpr
(
offset
)));
}
}
((
InsertSQLContext
)
result
).
getGeneratedKeyContext
().
getColumns
().
add
(
each
);
((
InsertSQLContext
)
result
).
getGeneratedKeyContext
().
putValue
(
each
,
generatedId
);
}
if
(!
valuesToken
.
getItems
().
isEmpty
())
{
result
.
getSqlBuilderContext
().
getSqlTokens
().
add
(
valuesToken
);
}
}
return
result
;
}
private
boolean
isIncluded
(
final
InsertSQLContext
insertSQLContext
,
final
String
autoIncrementColumn
)
{
for
(
ShardingColumnContext
shardingColumnContext
:
insertSQLContext
.
getShardingColumnContexts
())
{
if
(
shardingColumnContext
.
getColumnName
().
equalsIgnoreCase
(
autoIncrementColumn
))
{
return
true
;
}
}
return
false
;
}
private
SQLContext
buildHintParsedResult
(
final
String
logicSql
)
{
SQLContext
result
;
switch
(
SQLUtil
.
getTypeByStart
(
logicSql
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录