mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-13 03:13:41 +08:00
fix(test): 用生产配置初始化 system-setting 列名缓存
TableInfoHelper 写的是 JVM 级静态列名缓存,三个测试用原生 MyBatis Configuration 初始化,默认把属性映射成 camelCase 列名(settingKey 而非 setting_key),后写覆盖 先写,导致同一 surefire fork 内该实体的后续查询全部生成非法 SQL。 表现为 TeamControllerTest 抛 BadSqlGrammarException —— 而它本身并不查库: R.ok() 通过先前 Spring 上下文测试装上的静态 I18nService 解析消息,后者会读 mate_system_setting 的语言设置。单跑该类通过,全量跑失败。
This commit is contained in:
parent
7fb6ba7461
commit
88660caec8
@ -1,8 +1,8 @@
|
||||
package vip.mate.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -40,8 +40,14 @@ class SystemSettingBoolApiTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initTableInfo() {
|
||||
// MybatisConfiguration, not the plain MyBatis Configuration: the column
|
||||
// cache TableInfoHelper installs is static and JVM-wide, and a plain
|
||||
// Configuration maps properties to camelCase columns (settingKey rather
|
||||
// than setting_key). Seeding it that way poisons every later query on
|
||||
// this entity in the same surefire fork, including ones issued through
|
||||
// a Spring context.
|
||||
TableInfoHelper.initTableInfo(
|
||||
new MapperBuilderAssistant(new Configuration(), ""),
|
||||
new MapperBuilderAssistant(new MybatisConfiguration(), ""),
|
||||
SystemSettingEntity.class);
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package vip.mate.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
@ -44,8 +44,14 @@ class SystemSettingServiceCatalogTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initTableInfo() {
|
||||
// MybatisConfiguration, not the plain MyBatis Configuration: the column
|
||||
// cache TableInfoHelper installs is static and JVM-wide, and a plain
|
||||
// Configuration maps properties to camelCase columns (settingKey rather
|
||||
// than setting_key). Seeding it that way poisons every later query on
|
||||
// this entity in the same surefire fork, including ones issued through
|
||||
// a Spring context.
|
||||
TableInfoHelper.initTableInfo(
|
||||
new MapperBuilderAssistant(new Configuration(), ""),
|
||||
new MapperBuilderAssistant(new MybatisConfiguration(), ""),
|
||||
SystemSettingEntity.class);
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package vip.mate.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -56,8 +56,14 @@ class SystemSettingWorkspaceStorageRootTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initTableInfo() {
|
||||
// MybatisConfiguration, not the plain MyBatis Configuration: the column
|
||||
// cache TableInfoHelper installs is static and JVM-wide, and a plain
|
||||
// Configuration maps properties to camelCase columns (settingKey rather
|
||||
// than setting_key). Seeding it that way poisons every later query on
|
||||
// this entity in the same surefire fork, including ones issued through
|
||||
// a Spring context.
|
||||
TableInfoHelper.initTableInfo(
|
||||
new MapperBuilderAssistant(new Configuration(), ""),
|
||||
new MapperBuilderAssistant(new MybatisConfiguration(), ""),
|
||||
SystemSettingEntity.class);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user