baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.41k stars 4.31k forks source link

[功能改进]: TenantLineInnerInterceptor类里有一处代码需优化 #6370

Closed re-resolve closed 3 months ago

re-resolve commented 3 months ago

确认

功能改进

多租户插件TenantLineInnerInterceptor的源码有个很明显的问题: 代码分支:release v3.5.7 所处类:/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/TenantLineInnerInterceptor.java

// fixed gitee pulls/141 duplicate update
List<UpdateSet> duplicateUpdateColumns = insert.getDuplicateUpdateSets();
  if (CollectionUtils.isNotEmpty(duplicateUpdateColumns)) {
      EqualsTo equalsTo = new EqualsTo();
      equalsTo.setLeftExpression(new StringValue(tenantIdColumn));
      equalsTo.setRightExpression(tenantId);
      // 上面的equalsTo没被使用到
      duplicateUpdateColumns.add(new UpdateSet(new Column(tenantIdColumn), tenantId));
}

上面这里是否需要优化代码并测试?

参考资料

No response

nieqiurong commented 3 months ago

https://github.com/baomidou/mybatis-plus/blob/67f7ab7760a07f429e1c7d0c22282deb9fad9b19/mybatis-plus-extension/src/test/java/com/baomidou/mybatisplus/test/extension/plugins/inner/TenantLineInnerInterceptorTest.java#L462