From 398fe8e280faa9005f5d2685ff4bc1311219fda5 Mon Sep 17 00:00:00 2001 From: Willie Scholtz Date: Thu, 2 Jan 2025 11:44:37 +0100 Subject: [PATCH] Revert #3349 Regression when where node is used without new lines --- .../scripting/xmltags/XMLScriptBuilder.java | 5 +- .../xmltags/XMLScriptBuilderTest.java | 62 ------------------- 2 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 src/test/java/org/apache/ibatis/scripting/xmltags/XMLScriptBuilderTest.java diff --git a/src/main/java/org/apache/ibatis/scripting/xmltags/XMLScriptBuilder.java b/src/main/java/org/apache/ibatis/scripting/xmltags/XMLScriptBuilder.java index 8a5f01e94fa..6e9cafc1fb4 100644 --- a/src/main/java/org/apache/ibatis/scripting/xmltags/XMLScriptBuilder.java +++ b/src/main/java/org/apache/ibatis/scripting/xmltags/XMLScriptBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2025 the original author or authors. + * Copyright 2009-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,9 +80,6 @@ protected MixedSqlNode parseDynamicTags(XNode node) { XNode child = node.newXNode(children.item(i)); if (child.getNode().getNodeType() == Node.CDATA_SECTION_NODE || child.getNode().getNodeType() == Node.TEXT_NODE) { String data = child.getStringBody(""); - if (data.trim().isEmpty()) { - continue; - } TextSqlNode textSqlNode = new TextSqlNode(data); if (textSqlNode.isDynamic()) { contents.add(textSqlNode); diff --git a/src/test/java/org/apache/ibatis/scripting/xmltags/XMLScriptBuilderTest.java b/src/test/java/org/apache/ibatis/scripting/xmltags/XMLScriptBuilderTest.java deleted file mode 100644 index 66a542cb6ec..00000000000 --- a/src/test/java/org/apache/ibatis/scripting/xmltags/XMLScriptBuilderTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2009-2025 the original author or authors. - * - * Licensed 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 - * - * https://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.ibatis.scripting.xmltags; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; - -import java.lang.reflect.Field; -import java.util.List; - -import org.apache.ibatis.mapping.SqlSource; -import org.apache.ibatis.parsing.XPathParser; -import org.apache.ibatis.session.Configuration; -import org.junit.jupiter.api.Test; - -class XMLScriptBuilderTest { - - @Test - void shouldEmptyTextNodesRemoved() throws Exception { - String xml = """ - - """; - SqlSource sqlSource = new XMLScriptBuilder(new Configuration(), new XPathParser(xml).evalNode("/script")) - .parseScriptNode(); - - Field rootSqlNodeFld = DynamicSqlSource.class.getDeclaredField("rootSqlNode"); - rootSqlNodeFld.setAccessible(true); - MixedSqlNode sqlNode = (MixedSqlNode) rootSqlNodeFld.get(sqlSource); - - Field contentsFld = MixedSqlNode.class.getDeclaredField("contents"); - contentsFld.setAccessible(true); - @SuppressWarnings("unchecked") - List contents = (List) contentsFld.get(sqlNode); - - assertEquals(3, contents.size()); - assertThat(contents.get(0)).isInstanceOf(StaticTextSqlNode.class); - assertThat(contents.get(1)).isInstanceOf(IfSqlNode.class); - assertThat(contents.get(2)).isInstanceOf(IfSqlNode.class); - } - -}