This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 849875c4eb fix: correct namespaceId jdbcType bindings(#6718) (#7003)
849875c4eb is described below
commit 849875c4eb6750d208424921de207dbd8d24e65a
Author: Southern <[email protected]>
AuthorDate: Sat Sep 5 09:12:17 2026 +0800
fix: correct namespaceId jdbcType bindings(#6718) (#7003)
* fix: correct namespaceId jdbcType bindings
- Change meta_data insert namespaceId binding from TINYINT to VARCHAR
- Change namespace_plugin_rel query namespaceId binding from TINYINT to
VARCHAR
- Add mapper tests for string namespace IDs
* fix ci
---------
Co-authored-by: aias00 <[email protected]>
---
.../main/resources/mappers/meta-data-sqlmap.xml | 2 +-
.../mappers/namespace-plugin-rel-sqlmap.xml | 2 +-
.../shenyu/admin/mapper/MetaDataMapperTest.java | 10 ++++++++++
.../admin/mapper/NamespacePluginRelMapperTest.java | 23 ++++++++++++++++++++++
4 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/shenyu-admin/src/main/resources/mappers/meta-data-sqlmap.xml
b/shenyu-admin/src/main/resources/mappers/meta-data-sqlmap.xml
index 9093a3a920..ae8b6465e5 100644
--- a/shenyu-admin/src/main/resources/mappers/meta-data-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/meta-data-sqlmap.xml
@@ -197,7 +197,7 @@
#{parameterTypes,jdbcType=VARCHAR},
#{rpcExt,jdbcType=VARCHAR},
#{enabled,jdbcType=TINYINT},
- #{namespaceId,jdbcType=TINYINT})
+ #{namespaceId,jdbcType=VARCHAR})
</insert>
diff --git
a/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
b/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
index 53f4f3fcdf..062db4b192 100644
--- a/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
@@ -95,7 +95,7 @@
AND enabled = #{enabled, jdbcType=TINYINT}
</if>
<if test="namespaceId != null">
- AND namespace_id = #{namespaceId, jdbcType=TINYINT}
+ AND namespace_id = #{namespaceId, jdbcType=VARCHAR}
</if>
</where>
) npr
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MetaDataMapperTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MetaDataMapperTest.java
index 0cdfab610c..584dd4e21c 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MetaDataMapperTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MetaDataMapperTest.java
@@ -167,6 +167,16 @@ public final class MetaDataMapperTest extends
AbstractSpringIntegrationTest {
assertThat(after.get(0).getId(), comparesEqualTo(metaDataDO.getId()));
}
+ @Test
+ public void insertWithStringNamespaceId() {
+ MetaDataDO metaDataDO = getMetaDataDO();
+ String namespaceId = "namespace-text";
+ metaDataDO.setNamespaceId(namespaceId);
+
+ assertThat(metaDataMapper.insert(metaDataDO), comparesEqualTo(1));
+
assertThat(metaDataMapper.selectById(metaDataDO.getId()).getNamespaceId(),
comparesEqualTo(namespaceId));
+ }
+
@Test
public void update() {
MetaDataDO metaDataDO = getMetaDataDO();
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespacePluginRelMapperTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespacePluginRelMapperTest.java
index 57fcc9e022..52f3e5c4ab 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespacePluginRelMapperTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespacePluginRelMapperTest.java
@@ -20,6 +20,8 @@ package org.apache.shenyu.admin.mapper;
import jakarta.annotation.Resource;
import org.apache.shenyu.admin.AbstractSpringIntegrationTest;
import org.apache.shenyu.admin.model.entity.NamespacePluginRelDO;
+import org.apache.shenyu.admin.model.page.PageParameter;
+import org.apache.shenyu.admin.model.query.NamespacePluginQuery;
import org.apache.shenyu.admin.model.entity.PluginDO;
import org.apache.shenyu.admin.model.vo.NamespacePluginVO;
import org.apache.shenyu.common.utils.UUIDUtils;
@@ -60,6 +62,27 @@ class NamespacePluginRelMapperTest extends
AbstractSpringIntegrationTest {
Assertions.assertEquals(id, queryResults.get(0).getId());
}
+ @Test
+ void testSelectByQueryWithStringNamespaceId() {
+ String namespaceId = "namespace-text";
+ NamespacePluginRelDO relation = NamespacePluginRelDO.builder()
+ .id(UUIDUtils.getInstance().generateShortUuid())
+ .pluginId("plugin")
+ .namespaceId(namespaceId)
+ .config("{}")
+ .sort(0)
+ .enabled(false)
+ .dateCreated(new Timestamp(new java.util.Date().getTime()))
+ .dateUpdated(new Timestamp(new java.util.Date().getTime()))
+ .build();
+ namespacePluginRelMapper.insertSelective(relation);
+
+ NamespacePluginQuery query = new NamespacePluginQuery(null, null, new
PageParameter(), namespaceId);
+ List<NamespacePluginVO> results =
namespacePluginRelMapper.selectByQuery(query);
+ Assertions.assertFalse(results.isEmpty());
+ Assertions.assertEquals(namespaceId, results.get(0).getNamespaceId());
+ }
+
@Test
void testNameExistedExcludeUsesPluginName() {
String pluginId = UUIDUtils.getInstance().generateShortUuid();