Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
50f1cbbf
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,发现更多精彩内容 >>
提交
50f1cbbf
编写于
9月 01, 2019
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
for #2567, remove EncryptInsertOptimizedStatement.addInsertValue()
上级
9661bba4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
21 deletion
+10
-21
sharding-core/sharding-core-optimize/src/main/java/org/apache/shardingsphere/core/optimize/encrypt/engine/dml/EncryptInsertOptimizeEngine.java
...imize/encrypt/engine/dml/EncryptInsertOptimizeEngine.java
+10
-1
sharding-core/sharding-core-optimize/src/main/java/org/apache/shardingsphere/core/optimize/encrypt/statement/EncryptInsertOptimizedStatement.java
...ze/encrypt/statement/EncryptInsertOptimizedStatement.java
+0
-20
未找到文件。
sharding-core/sharding-core-optimize/src/main/java/org/apache/shardingsphere/core/optimize/encrypt/engine/dml/EncryptInsertOptimizeEngine.java
浏览文件 @
50f1cbbf
...
...
@@ -27,6 +27,7 @@ import org.apache.shardingsphere.core.rule.EncryptRule;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.LinkedList
;
import
java.util.List
;
/**
...
...
@@ -44,7 +45,8 @@ public final class EncryptInsertOptimizeEngine implements EncryptOptimizeEngine<
Collection
<
String
>
columnNames
=
sqlStatement
.
useDefaultColumns
()
?
tableMetas
.
getAllColumnNames
(
sqlStatement
.
getTable
().
getTableName
())
:
sqlStatement
.
getColumnNames
();
int
derivedColumnCount
=
encryptRule
.
getAssistedQueryAndPlainColumnCount
(
sqlStatement
.
getTable
().
getTableName
());
for
(
Collection
<
ExpressionSegment
>
each
:
sqlStatement
.
getAllValueExpressions
())
{
InsertValue
insertValue
=
result
.
addInsertValue
(
encryptDerivedColumnNames
,
each
,
derivedColumnCount
,
parameters
,
parametersOffset
);
InsertValue
insertValue
=
createInsertValue
(
columnNames
,
encryptDerivedColumnNames
,
each
,
derivedColumnCount
,
parameters
,
parametersOffset
);
result
.
getInsertValues
().
add
(
insertValue
);
Object
[]
currentParameters
=
insertValue
.
getParameters
();
if
(
encryptRule
.
containsQueryAssistedColumn
(
sqlStatement
.
getTable
().
getTableName
()))
{
fillAssistedQueryInsertValue
(
encryptRule
,
Arrays
.
asList
(
currentParameters
),
sqlStatement
.
getTable
().
getTableName
(),
columnNames
,
insertValue
);
...
...
@@ -57,6 +59,13 @@ public final class EncryptInsertOptimizeEngine implements EncryptOptimizeEngine<
return
result
;
}
private
InsertValue
createInsertValue
(
final
Collection
<
String
>
columnNames
,
final
Collection
<
String
>
derivedColumnNames
,
final
Collection
<
ExpressionSegment
>
assignments
,
final
int
derivedColumnsCount
,
final
List
<
Object
>
parameters
,
final
int
parametersOffset
)
{
List
<
String
>
allColumnNames
=
new
LinkedList
<>(
columnNames
);
allColumnNames
.
addAll
(
derivedColumnNames
);
return
new
InsertValue
(
allColumnNames
,
assignments
,
derivedColumnsCount
,
parameters
,
parametersOffset
);
}
private
void
fillAssistedQueryInsertValue
(
final
EncryptRule
encryptRule
,
final
List
<
Object
>
parameters
,
final
String
tableName
,
final
Collection
<
String
>
columnNames
,
final
InsertValue
insertValue
)
{
for
(
String
each
:
columnNames
)
{
...
...
sharding-core/sharding-core-optimize/src/main/java/org/apache/shardingsphere/core/optimize/encrypt/statement/EncryptInsertOptimizedStatement.java
浏览文件 @
50f1cbbf
...
...
@@ -24,7 +24,6 @@ import org.apache.shardingsphere.core.metadata.table.TableMetas;
import
org.apache.shardingsphere.core.optimize.api.segment.InsertValue
;
import
org.apache.shardingsphere.core.optimize.api.segment.Tables
;
import
org.apache.shardingsphere.core.optimize.api.statement.InsertOptimizedStatement
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.expr.ExpressionSegment
;
import
org.apache.shardingsphere.core.parse.sql.statement.SQLStatement
;
import
org.apache.shardingsphere.core.parse.sql.statement.dml.InsertStatement
;
...
...
@@ -56,25 +55,6 @@ public final class EncryptInsertOptimizedStatement implements InsertOptimizedSta
columnNames
=
sqlStatement
.
useDefaultColumns
()
?
tableMetas
.
getAllColumnNames
(
sqlStatement
.
getTable
().
getTableName
())
:
sqlStatement
.
getColumnNames
();
}
/**
* Add insert value.
*
* @param derivedColumnNames derived column names
* @param assignments assignments
* @param derivedColumnsCount derived columns count
* @param parameters SQL parameters
* @param parametersOffset offset of SQL parameters
* @return insert value
*/
public
InsertValue
addInsertValue
(
final
Collection
<
String
>
derivedColumnNames
,
final
Collection
<
ExpressionSegment
>
assignments
,
final
int
derivedColumnsCount
,
final
List
<
Object
>
parameters
,
final
int
parametersOffset
)
{
List
<
String
>
allColumnNames
=
new
LinkedList
<>(
columnNames
);
allColumnNames
.
addAll
(
derivedColumnNames
);
InsertValue
result
=
new
InsertValue
(
allColumnNames
,
assignments
,
derivedColumnsCount
,
parameters
,
parametersOffset
);
insertValues
.
add
(
result
);
return
result
;
}
@Override
public
SQLStatement
getSQLStatement
()
{
return
sqlStatement
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录