mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
This commit is contained in:
parent
cace18d3bb
commit
5a29504927
@ -245,7 +245,7 @@ public class UpdateJoinWrapper<T> extends JoinAbstractLambdaWrapper<T, UpdateJoi
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
private void getSqlByEntity(StringBuilder sb, boolean filterNull, List<Object> entityList) {
|
||||
for (Object obj : entityList) {
|
||||
Assert.isTrue(tableList.contain(obj.getClass()), "更新的实体不是主表或关联表 <%>", obj.getClass().getSimpleName());
|
||||
Assert.isTrue(tableList.contain(obj.getClass()), "更新的实体不是主表或关联表 <%s>", obj.getClass().getSimpleName());
|
||||
TableInfo tableInfo = TableHelper.getAssert(obj.getClass());
|
||||
for (TableFieldInfo fieldInfo : tableInfo.getFieldList()) {
|
||||
if (AdapterHelper.getAdapter().mpjHasLogic(tableInfo) && fieldInfo.isLogicDelete()) {
|
||||
@ -266,7 +266,7 @@ public class UpdateJoinWrapper<T> extends JoinAbstractLambdaWrapper<T, UpdateJoi
|
||||
continue;
|
||||
}
|
||||
sb.append(tableList.getPrefixByClass(obj.getClass())).append(Constants.DOT)
|
||||
.append(fieldInfo.getColumn()).append(Constants.EQUALS).append(formatParam(null, val))
|
||||
.append(fieldInfo.getColumn()).append(Constants.EQUALS).append(formatParam(fieldInfo.getMapping(), val))
|
||||
.append(StringPool.COMMA);
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,29 @@
|
||||
package com.github.yulichang.test.join.m;
|
||||
|
||||
import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
|
||||
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
||||
import com.github.yulichang.test.join.entity.AddressDO;
|
||||
import com.github.yulichang.test.join.entity.UserDO;
|
||||
import com.github.yulichang.test.join.mapper.UserMapper;
|
||||
import com.github.yulichang.test.util.Reset;
|
||||
import com.github.yulichang.test.util.ThreadLocalUtils;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.UpdateJoinWrapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.jdbc.BadSqlGrammarException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
public class UpdateIncTest {
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
Reset.reset();
|
||||
@ -44,4 +55,28 @@ public class UpdateIncTest {
|
||||
JoinWrappers.lambda(UserDO.class).list().forEach(System.out::println);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateInc2() {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("aaa", "bbb");
|
||||
|
||||
UserDO userDO = new UserDO();
|
||||
userDO.setJson(map);
|
||||
|
||||
InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
|
||||
|
||||
UpdateJoinWrapper<UserDO> wrapper = JoinWrappers.update(UserDO.class)
|
||||
.setUpdateEntity(userDO);
|
||||
|
||||
userMapper.updateJoin(null, wrapper);
|
||||
|
||||
InterceptorIgnoreHelper.clearIgnoreStrategy();
|
||||
|
||||
List<UserDO> list = JoinWrappers.lambda(UserDO.class).list();
|
||||
list.forEach(System.out::println);
|
||||
list.forEach(c -> {
|
||||
assert c.getJson().get("aaa").equals("bbb");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user