fix: insertSelectiveWithPk 方法 给主键赋值后会拼接两次id, close #I7L6DF

This commit is contained in:
开源海哥 2023-07-14 14:41:38 +08:00
parent 082b574bd0
commit 7c30bb217d
3 changed files with 55 additions and 35 deletions

View File

@ -479,7 +479,7 @@ public class TableInfo {
retColumns.add(insertColumn); retColumns.add(insertColumn);
} }
} }
return ArrayUtil.concat(insertPrimaryKeys, retColumns.toArray(new String[0])); return retColumns.toArray(new String[0]);
} }
} }

View File

@ -32,6 +32,7 @@ public class Account extends BaseEntity implements Serializable, AgeAware {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// @Id(keyType = KeyType.Generator,value = "uuid")
@Id(keyType = KeyType.Auto) @Id(keyType = KeyType.Auto)
@ColumnAlias("account_id") @ColumnAlias("account_id")
private Long id; private Long id;

View File

@ -107,5 +107,24 @@ public class AccountTester {
} }
/**
* https://gitee.com/mybatis-flex/mybatis-flex/issues/I7L6DF
*/
@Test
public void testInsertSelectiveWithPk() {
List<Account> accounts = accountMapper.selectAll();
System.out.println(accounts);
Account account = new Account();
account.setId(4L);
account.setUserName("test04");
accountMapper.insertSelectiveWithPk(account);
accounts = accountMapper.selectAll();
System.out.println(accounts);
}
} }