This is an automated email from the ASF dual-hosted git repository.
mattcasters pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new c663ca7035 Fix SQL token merging when removing comments (#7501)
c663ca7035 is described below
commit c663ca70358f24e39b82079fd6770cdb9842e592
Author: Gabriel Dutra <[email protected]>
AuthorDate: Sat Jul 11 15:55:19 2026 -0700
Fix SQL token merging when removing comments (#7501)
Co-authored-by: gabrieldutra <[email protected]>
---
.../java/org/apache/hop/core/database/SqlScriptParser.java | 10 ++++++++++
.../java/org/apache/hop/core/database/SqlScriptParserTest.java | 1 +
2 files changed, 11 insertions(+)
diff --git
a/core/src/main/java/org/apache/hop/core/database/SqlScriptParser.java
b/core/src/main/java/org/apache/hop/core/database/SqlScriptParser.java
index 1837e456cb..63e5d1f85f 100644
--- a/core/src/main/java/org/apache/hop/core/database/SqlScriptParser.java
+++ b/core/src/main/java/org/apache/hop/core/database/SqlScriptParser.java
@@ -198,6 +198,12 @@ public class SqlScriptParser {
if (ch == '*' && nextCh == '/') {
mode = MODE.SQL;
i = i + 1;
+ if (!result.isEmpty()
+ && i + 1 < script.length()
+ && isSqlWordCharacter(result.charAt(result.length() - 1))
+ && isSqlWordCharacter(script.charAt(i + 1))) {
+ result.append(' ');
+ }
}
ch = 0;
break;
@@ -243,4 +249,8 @@ public class SqlScriptParser {
return result.toString();
}
+
+ private static boolean isSqlWordCharacter(char ch) {
+ return Character.isLetterOrDigit(ch) || ch == '_' || ch == '$';
+ }
}
diff --git
a/core/src/test/java/org/apache/hop/core/database/SqlScriptParserTest.java
b/core/src/test/java/org/apache/hop/core/database/SqlScriptParserTest.java
index 418a1b0898..b2247d8d60 100644
--- a/core/src/test/java/org/apache/hop/core/database/SqlScriptParserTest.java
+++ b/core/src/test/java/org/apache/hop/core/database/SqlScriptParserTest.java
@@ -93,6 +93,7 @@ class SqlScriptParserTest {
"SELECT col1 FROM account",
sqlScriptParser.removeComments(
"SELECT /* \"my_column'\" */ col1 FROM /* 'my_table' */ account"));
+ assertEquals("SELECT 1", sqlScriptParser.removeComments("SELECT/* comment
*/1"));
assertEquals(
"SELECT '/' as col1, '*/*' as regex ",
sqlScriptParser.removeComments("SELECT '/' as col1, '*/*' as regex "));