修复:租户模式下,deleteBatchByIds报错。close #I6W0I4

This commit is contained in:
开源海哥 2023-04-16 09:26:10 +08:00
parent fe94c30b22
commit fdfbad3d0a
2 changed files with 13 additions and 15 deletions

View File

@ -150,7 +150,8 @@ public class EntitySqlProvider {
TableInfo tableInfo = ProviderUtil.getTableInfo(context);
ProviderUtil.setSqlArgs(params, primaryValues);
Object[] tenantIdArgs = tableInfo.buildTenantIdArgs();
ProviderUtil.setSqlArgs(params, ArrayUtil.concat(primaryValues,tenantIdArgs));
return DialectFactory.getDialect().forDeleteEntityBatchByIds(tableInfo, primaryValues);
}

View File

@ -18,7 +18,6 @@ package com.mybatisflex.test;
import com.mybatisflex.core.MybatisFlexBootstrap;
import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.core.audit.ConsoleMessageCollector;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.tenant.TenantFactory;
import com.mybatisflex.core.tenant.TenantManager;
import com.mybatisflex.mapper.TenantAccountMapper;
@ -27,10 +26,6 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import javax.sql.DataSource;
import static com.mybatisflex.core.query.QueryMethods.select;
import static com.mybatisflex.test.table.Tables.ACCOUNT;
import static com.mybatisflex.test.table.Tables.TENANT_ACCOUNT;
public class TenantTester {
public static void main(String[] args) {
@ -61,15 +56,17 @@ public class TenantTester {
TenantAccountMapper mapper = MybatisFlexBootstrap.getInstance().getMapper(TenantAccountMapper.class);
mapper.selectListByQuery(QueryWrapper.create()
.select(TENANT_ACCOUNT.ALL_COLUMNS)
.from(TENANT_ACCOUNT.as("c"), ACCOUNT.as("b"))
.where(TENANT_ACCOUNT.ID.eq(ACCOUNT.ID))
.and(TENANT_ACCOUNT.ID.eq(1))
.unionAll(select(TENANT_ACCOUNT.ALL_COLUMNS).from(TENANT_ACCOUNT)
.where(TENANT_ACCOUNT.ID.eq(2))
)
);
// mapper.selectListByQuery(QueryWrapper.create()
// .select(TENANT_ACCOUNT.ALL_COLUMNS)
// .from(TENANT_ACCOUNT.as("c"), ACCOUNT.as("b"))
// .where(TENANT_ACCOUNT.ID.eq(ACCOUNT.ID))
// .and(TENANT_ACCOUNT.ID.eq(1))
// .unionAll(select(TENANT_ACCOUNT.ALL_COLUMNS).from(TENANT_ACCOUNT)
// .where(TENANT_ACCOUNT.ID.eq(2))
// )
// );
// mapper.deleteBatchByIds(Arrays.asList(1, 2));
//
// //SELECT * FROM `tb_account` WHERE `tenant_id` = 1