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 502f107157 fix(admin): use two-argument CONCAT for Oracle 
operation-log searches (#7738) (#7756)
502f107157 is described below

commit 502f1071577eb7470bcd3607eabe876c6fa351f6
Author: konlue <[email protected]>
AuthorDate: Mon Oct 19 14:23:17 2026 +0800

    fix(admin): use two-argument CONCAT for Oracle operation-log searches 
(#7738) (#7756)
---
 .../mappers/operation-record-log-sqlmap.xml        |  4 +-
 .../mapper/OperationRecordLogConcatSqlTest.java    | 61 ++++++++++++++++++++++
 2 files changed, 63 insertions(+), 2 deletions(-)

diff --git 
a/shenyu-admin/src/main/resources/mappers/operation-record-log-sqlmap.xml 
b/shenyu-admin/src/main/resources/mappers/operation-record-log-sqlmap.xml
index e0666aea14..6440e37611 100644
--- a/shenyu-admin/src/main/resources/mappers/operation-record-log-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/operation-record-log-sqlmap.xml
@@ -72,10 +72,10 @@
         from operation_record_log
         where operation_time between #{condition.startTime} and 
#{condition.endTime}
         <if test="condition.keyword != null and condition.keyword != ''">
-            and context like concat('%',#{condition.keyword},'%')
+            and context like concat(concat('%',#{condition.keyword}),'%')
         </if>
         <if test="condition.excluded != null and condition.excluded != ''">
-            and context not like concat('%',#{condition.excluded},'%')
+            and context not like concat(concat('%',#{condition.excluded}),'%')
         </if>
         <if test="condition.type != null">
             and operation_type = #{condition.type}
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/OperationRecordLogConcatSqlTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/OperationRecordLogConcatSqlTest.java
new file mode 100644
index 0000000000..22021811ad
--- /dev/null
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/OperationRecordLogConcatSqlTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.RecordLogQueryCondition;
+import org.junit.jupiter.api.Test;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Verifies the operation-log keyword search uses Oracle-compatible CONCAT.
+ */
+public final class OperationRecordLogConcatSqlTest {
+
+    @Test
+    public void testKeywordSearchUsesTwoArgumentConcat() throws Exception {
+        Configuration configuration = new Configuration();
+        configuration.setDatabaseId("oracle");
+        try (InputStream in = 
Resources.getResourceAsStream("mappers/operation-record-log-sqlmap.xml")) {
+            new XMLMapperBuilder(in, configuration,
+                    "mappers/operation-record-log-sqlmap.xml", 
configuration.getSqlFragments()).parse();
+        }
+        RecordLogQueryCondition condition = new RecordLogQueryCondition();
+        condition.setKeyword("keyword");
+        condition.setExcluded("excluded");
+        Map<String, Object> parameters = new HashMap<>();
+        parameters.put("condition", condition);
+        BoundSql boundSql = configuration
+                
.getMappedStatement("org.apache.shenyu.admin.mapper.OperationRecordLogMapper.selectByCondition")
+                .getBoundSql(parameters);
+        String sql = boundSql.getSql().toLowerCase(Locale.ROOT);
+        String compact = sql.replaceAll("\\s+", "");
+        assertFalse(compact.contains("concat('%',?,'%')"), sql);
+        assertTrue(compact.contains("concat(concat('%',?),'%')"), sql);
+    }
+}

Reply via email to