Skip to content

Commit

Permalink
bugfix: bypass modify the primary key (#4953)
Browse files Browse the repository at this point in the history
  • Loading branch information
funky-eyes authored Sep 29, 2022
1 parent 5f2acb5 commit d0f324c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changes/en-us/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Add changes here for all PR submitted to the develop branch.
- [[#4915](https://github.com/seata/seata/pull/4915)] fix failed to get server recovery properties
- [[#4919](https://github.com/seata/seata/pull/4919)] fix XID port and address null:0 before coordinator.init
- [[#4928](https://github.com/seata/seata/pull/4928)] fix rpcContext.getClientRMHolderMap NPE

- [[#4953](https://github.com/seata/seata/pull/4953)] fix InsertOnDuplicateUpdate bypass modify pk

### optimize:
- [[#4774](https://github.com/seata/seata/pull/4774)] optimize mysql8 dependencies for seataio/seata-server image
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- [[#4915](https://github.com/seata/seata/pull/4915)] 修复获取不到ServerRecoveryProperties属性的问题
- [[#4919](https://github.com/seata/seata/pull/4919)] 修复XID的port和address出现null:0的情况
- [[#4928](https://github.com/seata/seata/pull/4928)] 修复 rpcContext.getClientRMHolderMap NPE 问题
- [[#4953](https://github.com/seata/seata/pull/4953)] 修复InsertOnDuplicateUpdate可绕过修改主键的问题

### optimize:
- [[#4774](https://github.com/seata/seata/pull/4774)] 优化 seataio/seata-server 镜像中的 mysql8 依赖
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Map;
import java.util.Collections;
import java.util.StringJoiner;
import java.util.stream.Collectors;

import com.google.common.base.Joiner;
import io.seata.common.exception.NotSupportYetException;
Expand Down Expand Up @@ -346,10 +347,12 @@ public String buildImageSQL(TableMeta tableMeta) {
public Map<String, ArrayList<Object>> buildImageParameters(SQLInsertRecognizer recognizer) {
List<String> duplicateKeyUpdateColumns = recognizer.getDuplicateKeyUpdate();
if (CollectionUtils.isNotEmpty(duplicateKeyUpdateColumns)) {
List<String> duplicateKeyUpdateLowerCaseColumns =
duplicateKeyUpdateColumns.parallelStream().map(String::toLowerCase).collect(Collectors.toList());
getTableMeta().getAllIndexes().forEach((k, v) -> {
if ("PRIMARY".equalsIgnoreCase(k)) {
for (ColumnMeta m : v.getValues()) {
if (duplicateKeyUpdateColumns.contains(m.getColumnName())) {
if (duplicateKeyUpdateLowerCaseColumns.contains(m.getColumnName().toLowerCase())) {
throw new ShouldNeverHappenException("update pk value is not supported!");
}
}
Expand Down

0 comments on commit d0f324c

Please sign in to comment.