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 67ef2b4f54 fix(admin): use ROWNUM for the Oracle instance identity
lookup (#7724) (#7754)
67ef2b4f54 is described below
commit 67ef2b4f546c4dc785ca72ec78e648a684ad28ba
Author: konlue <[email protected]>
AuthorDate: Sun Oct 18 08:27:01 2026 +0800
fix(admin): use ROWNUM for the Oracle instance identity lookup (#7724)
(#7754)
---
.../resources/mappers/instance-info-sqlmap.xml | 23 ++++++++
.../mapper/InstanceInfoMapperOracleSqlTest.java | 62 ++++++++++++++++++++++
2 files changed, 85 insertions(+)
diff --git a/shenyu-admin/src/main/resources/mappers/instance-info-sqlmap.xml
b/shenyu-admin/src/main/resources/mappers/instance-info-sqlmap.xml
index e278d682cf..0160e66e42 100644
--- a/shenyu-admin/src/main/resources/mappers/instance-info-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/instance-info-sqlmap.xml
@@ -131,6 +131,29 @@
LIMIT 1
</select>
+ <select databaseId="oracle" id="selectOneByQuery"
resultType="org.apache.shenyu.admin.model.entity.InstanceInfoDO">
+ SElECT
+ <include refid="Base_Column_List"/>
+ FROM instance_info
+ WHERE 1=1
+ <if test="instanceIp != null and instanceIp != ''">
+ AND instance_ip = #{instanceIp}
+ </if>
+ <if test="namespaceId != null and namespaceId != ''">
+ AND namespace_id = #{namespaceId}
+ </if>
+ <if test="instancePort != null and instancePort != ''">
+ AND instance_port = #{instancePort}
+ </if>
+ <if test="instanceType != null and instanceType != ''">
+ AND instance_type = #{instanceType}
+ </if>
+ <if test="instanceId != null and instanceId != ''">
+ AND id = #{instanceId}
+ </if>
+ AND ROWNUM = 1
+ </select>
+
<insert id="insert"
parameterType="org.apache.shenyu.admin.model.entity.InstanceInfoDO">
INSERT INTO instance_info
(id,
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/InstanceInfoMapperOracleSqlTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/InstanceInfoMapperOracleSqlTest.java
new file mode 100644
index 0000000000..7f33463aba
--- /dev/null
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/InstanceInfoMapperOracleSqlTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.apache.ibatis.builder.xml.XMLMapperBuilder;
+import org.apache.ibatis.io.Resources;
+import org.apache.ibatis.mapping.BoundSql;
+import org.apache.ibatis.session.Configuration;
+import org.apache.shenyu.admin.model.query.InstanceQuery;
+import org.junit.jupiter.api.Test;
+
+import java.io.InputStream;
+import java.util.Locale;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Verifies the Oracle variant of the instance mapper statements.
+ */
+public final class InstanceInfoMapperOracleSqlTest {
+
+ @Test
+ public void testSelectOneByQueryUsesOracleRowLimiting() throws Exception {
+ Configuration configuration = new Configuration();
+ configuration.setDatabaseId("oracle");
+ try (InputStream in =
Resources.getResourceAsStream("mappers/instance-info-sqlmap.xml")) {
+ new XMLMapperBuilder(in, configuration,
+ "mappers/instance-info-sqlmap.xml",
configuration.getSqlFragments()).parse();
+ }
+ InstanceQuery query = new InstanceQuery();
+ query.setInstanceIp("127.0.0.1");
+ query.setInstancePort("8080");
+ query.setInstanceType("grpc");
+ query.setNamespaceId("ns");
+ BoundSql boundSql = configuration
+
.getMappedStatement("org.apache.shenyu.admin.mapper.InstanceInfoMapper.selectOneByQuery")
+ .getBoundSql(query);
+ String sql =
boundSql.getSql().toLowerCase(Locale.ROOT).replaceAll("\\s+", " ");
+ assertTrue(sql.contains("rownum"), sql);
+ assertFalse(sql.contains("limit"), sql);
+ assertTrue(sql.contains("instance_ip = ?"), sql);
+ assertTrue(sql.contains("namespace_id = ?"), sql);
+ assertTrue(sql.contains("instance_port = ?"), sql);
+ assertTrue(sql.contains("instance_type = ?"), sql);
+ }
+}