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 00cfc49671 fix: correct namespace user relation batch save bindings
(#6991)
00cfc49671 is described below
commit 00cfc49671646074de270126ffe068de0121bdd4
Author: Southern <[email protected]>
AuthorDate: Fri Sep 4 07:35:15 2026 +0800
fix: correct namespace user relation batch save bindings (#6991)
Co-authored-by: aias00 <[email protected]>
---
.../mappers/namespace-user-rel-sqlmap.xml | 10 ++--
.../admin/mapper/NamespaceUserRelSqlMapTest.java | 56 ++++++++++++++++++++++
2 files changed, 61 insertions(+), 5 deletions(-)
diff --git
a/shenyu-admin/src/main/resources/mappers/namespace-user-rel-sqlmap.xml
b/shenyu-admin/src/main/resources/mappers/namespace-user-rel-sqlmap.xml
index 3ef2ef6071..0bd2ed3891 100644
--- a/shenyu-admin/src/main/resources/mappers/namespace-user-rel-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/namespace-user-rel-sqlmap.xml
@@ -103,11 +103,11 @@
VALUES
<foreach collection="namespaceUserRelDOList" item="namespaceUserRelDO"
separator=",">
(
- #{namespacePluginRelDO.id, jdbcType=VARCHAR},
- #{namespacePluginRelDO.namespaceId, jdbcType=VARCHAR},
- #{namespacePluginRelDO.userId, jdbcType=VARCHAR},
- #{namespacePluginRelDO.dateCreated, jdbcType=TIMESTAMP},
- #{namespacePluginRelDO.dateUpdated, jdbcType=TIMESTAMP})
+ #{namespaceUserRelDO.id, jdbcType=VARCHAR},
+ #{namespaceUserRelDO.namespaceId, jdbcType=VARCHAR},
+ #{namespaceUserRelDO.userId, jdbcType=VARCHAR},
+ #{namespaceUserRelDO.dateCreated, jdbcType=TIMESTAMP},
+ #{namespaceUserRelDO.dateUpdated, jdbcType=TIMESTAMP})
</foreach>
</insert>
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespaceUserRelSqlMapTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespaceUserRelSqlMapTest.java
new file mode 100644
index 0000000000..3720697742
--- /dev/null
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespaceUserRelSqlMapTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.mapper;
+
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Objects;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Test cases for namespace-user-rel-sqlmap.
+ */
+class NamespaceUserRelSqlMapTest {
+
+ private static final String MAPPER_RESOURCE =
"mappers/namespace-user-rel-sqlmap.xml";
+
+ @Test
+ void batchSaveShouldUseForeachItemForAllBindings() throws IOException {
+ String mapper = readMapper();
+
+ assertTrue(mapper.contains("<foreach
collection=\"namespaceUserRelDOList\" item=\"namespaceUserRelDO\""));
+ List.of("id", "namespaceId", "userId", "dateCreated",
"dateUpdated").forEach(property ->
+ assertTrue(mapper.contains("#{namespaceUserRelDO." + property
+ ",")));
+ assertFalse(mapper.contains("#{namespacePluginRelDO."));
+ }
+
+ private String readMapper() throws IOException {
+ try (InputStream inputStream =
getClass().getClassLoader().getResourceAsStream(MAPPER_RESOURCE)) {
+ if (Objects.isNull(inputStream)) {
+ throw new IOException("Mapper resource not found: " +
MAPPER_RESOURCE);
+ }
+ return new String(inputStream.readAllBytes(),
StandardCharsets.UTF_8);
+ }
+ }
+}