Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
3eb4d1ea
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,发现更多精彩内容 >>
提交
3eb4d1ea
编写于
9月 06, 2019
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
for #2567, refactor InsertValue.setValue()
上级
5cbd3dac
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
9 deletion
+9
-9
sharding-core/sharding-core-optimize/src/main/java/org/apache/shardingsphere/core/optimize/api/segment/InsertValue.java
...shardingsphere/core/optimize/api/segment/InsertValue.java
+6
-6
sharding-core/sharding-core-optimize/src/test/java/org/apache/shardingsphere/core/optimize/sharding/segment/insert/InsertOptimizedStatementTest.java
...sharding/segment/insert/InsertOptimizedStatementTest.java
+2
-2
sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/SQLRewriteEngine.java
.../apache/shardingsphere/core/rewrite/SQLRewriteEngine.java
+1
-1
未找到文件。
sharding-core/sharding-core-optimize/src/main/java/org/apache/shardingsphere/core/optimize/api/segment/InsertValue.java
浏览文件 @
3eb4d1ea
...
...
@@ -116,15 +116,15 @@ public final class InsertValue {
/**
* Set value.
*
* @param
columnName column name
* @param
index index
* @param value value
*/
public
void
setValue
(
final
String
columnName
,
final
Object
value
)
{
ExpressionSegment
expressionSegment
=
valueExpressions
.
get
(
columnNames
.
indexOf
(
columnName
)
);
if
(
expressionSegment
instanceof
ParameterMarkerExpressionSegment
)
{
parameters
.
set
(
getParameterIndex
(
expressionSegment
),
value
);
public
void
setValue
(
final
int
index
,
final
Object
value
)
{
ExpressionSegment
valueExpression
=
valueExpressions
.
get
(
index
);
if
(
valueExpression
instanceof
ParameterMarkerExpressionSegment
)
{
parameters
.
set
(
getParameterIndex
(
valueExpression
),
value
);
}
else
{
valueExpressions
.
set
(
columnNames
.
indexOf
(
columnName
),
new
LiteralExpressionSegment
(
expressionSegment
.
getStartIndex
(),
expressionSegment
.
getStopIndex
(),
value
));
valueExpressions
.
set
(
index
,
new
LiteralExpressionSegment
(
valueExpression
.
getStartIndex
(),
valueExpression
.
getStopIndex
(),
value
));
}
}
...
...
sharding-core/sharding-core-optimize/src/test/java/org/apache/shardingsphere/core/optimize/sharding/segment/insert/InsertOptimizedStatementTest.java
浏览文件 @
3eb4d1ea
...
...
@@ -51,9 +51,9 @@ public final class InsertOptimizedStatementTest {
assertThat
(
insertClauseOptimizedStatement
.
getInsertValues
().
get
(
0
).
getDataNodes
().
size
(),
is
(
0
));
assertThat
(
insertClauseOptimizedStatement
.
getInsertValues
().
get
(
0
).
getValue
(
1
),
is
((
Object
)
"parameter"
));
assertThat
(
insertClauseOptimizedStatement
.
getInsertValues
().
get
(
0
).
getValue
(
2
),
is
((
Object
)
"test"
));
insertClauseOptimizedStatement
.
getInsertValues
().
get
(
0
).
setValue
(
"id"
,
2
);
insertClauseOptimizedStatement
.
getInsertValues
().
get
(
0
).
setValue
(
0
,
2
);
assertThat
(
insertClauseOptimizedStatement
.
getInsertValues
().
get
(
0
).
getValue
(
0
),
is
((
Object
)
2
));
insertClauseOptimizedStatement
.
getInsertValues
().
get
(
0
).
setValue
(
"value"
,
"parameter1"
);
insertClauseOptimizedStatement
.
getInsertValues
().
get
(
0
).
setValue
(
1
,
"parameter1"
);
assertThat
(
insertClauseOptimizedStatement
.
getInsertValues
().
get
(
0
).
getValue
(
1
),
is
((
Object
)
"parameter1"
));
}
}
sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/SQLRewriteEngine.java
浏览文件 @
3eb4d1ea
...
...
@@ -128,7 +128,7 @@ public final class SQLRewriteEngine {
private
void
encryptInsertValue
(
final
EncryptRule
encryptRule
,
final
ShardingEncryptor
shardingEncryptor
,
final
String
tableName
,
final
int
columnIndex
,
final
InsertValue
insertValue
,
final
String
encryptLogicColumnName
)
{
Object
originalValue
=
insertValue
.
getValue
(
columnIndex
);
insertValue
.
setValue
(
encryptLogicColumnName
,
shardingEncryptor
.
encrypt
(
originalValue
));
insertValue
.
setValue
(
columnIndex
,
shardingEncryptor
.
encrypt
(
originalValue
));
if
(
shardingEncryptor
instanceof
ShardingQueryAssistedEncryptor
)
{
Optional
<
String
>
assistedColumnName
=
encryptRule
.
findAssistedQueryColumn
(
tableName
,
encryptLogicColumnName
);
Preconditions
.
checkArgument
(
assistedColumnName
.
isPresent
(),
"Can not find assisted query Column Name"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录