miemie 4 vuotta sitten
vanhempi
commit
409cbde142

+ 32 - 0
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/test/metadata/TableInfoHelperTest.java

@@ -185,4 +185,36 @@ class TableInfoHelperTest {
         @Version
         @Version
         private Integer version2;
         private Integer version2;
     }
     }
+
+    @Test
+    void testTableNamePrefix() {
+        MybatisConfiguration configuration = new MybatisConfiguration();
+        GlobalConfig config = GlobalConfigUtils.defaults();
+        config.getDbConfig().setTablePrefix("ttt_");
+        GlobalConfigUtils.setGlobalConfig(configuration, config);
+        TableInfo tableInfo = TableInfoHelper.initTableInfo(new MapperBuilderAssistant(configuration, ""), Table.class);
+        assertThat(tableInfo.getTableName()).isEqualTo("xxx");
+    }
+
+    @Test
+    void testTableNamePrefix2() {
+        MybatisConfiguration configuration = new MybatisConfiguration();
+        GlobalConfig config = GlobalConfigUtils.defaults();
+        config.getDbConfig().setTablePrefix("ttt_");
+        GlobalConfigUtils.setGlobalConfig(configuration, config);
+        TableInfo tableInfo = TableInfoHelper.initTableInfo(new MapperBuilderAssistant(configuration, ""), Table.class);
+        assertThat(tableInfo.getTableName()).isEqualTo("ttt_xxx");
+    }
+
+    @Data
+    @TableName("xxx")
+    private static class Table {
+
+    }
+
+    @Data
+    @TableName(value = "xxx", keepGlobalPrefix = true)
+    private static class Table2 {
+
+    }
 }
 }