This is an automated email from the ASF dual-hosted git repository.
gvdutra 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 51f7f41668 Fix catalog and schema identifier quoting (#7650)
51f7f41668 is described below
commit 51f7f4166865668f945d66775ea2df9e40a93710
Author: Gabriel Dutra <[email protected]>
AuthorDate: Mon Jul 27 15:37:43 2026 -0700
Fix catalog and schema identifier quoting (#7650)
---
.../org/apache/hop/core/database/DatabaseMeta.java | 14 +++++++++++++-
.../org/apache/hop/core/database/DatabaseMetaTest.java | 18 ++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/org/apache/hop/core/database/DatabaseMeta.java
b/core/src/main/java/org/apache/hop/core/database/DatabaseMeta.java
index 12e65b8e6e..a51c803a7d 100644
--- a/core/src/main/java/org/apache/hop/core/database/DatabaseMeta.java
+++ b/core/src/main/java/org/apache/hop/core/database/DatabaseMeta.java
@@ -1082,10 +1082,22 @@ public class DatabaseMeta extends HopMetadataBase
implements Cloneable, IHopMeta
}
} else {
return iDatabase.getSchemaTableCombination(
- quoteField(variables.resolve(schemaName)),
quoteField(variables.resolve(tableName)));
+ quoteSchema(variables.resolve(schemaName)),
quoteField(variables.resolve(tableName)));
}
}
+ private String quoteSchema(String schemaName) {
+ if (supportsCatalogs()) {
+ int separatorIndex = schemaName.indexOf('.');
+ if (separatorIndex > 0 && separatorIndex < schemaName.length() - 1) {
+ String catalogName = schemaName.substring(0, separatorIndex);
+ String schemaPart = schemaName.substring(separatorIndex + 1);
+ return quoteField(catalogName) + "." + quoteField(schemaPart);
+ }
+ }
+ return quoteField(schemaName);
+ }
+
public boolean isClob(IValueMeta v) {
boolean retval = true;
diff --git
a/core/src/test/java/org/apache/hop/core/database/DatabaseMetaTest.java
b/core/src/test/java/org/apache/hop/core/database/DatabaseMetaTest.java
index 44b095e82a..efc45966e2 100644
--- a/core/src/test/java/org/apache/hop/core/database/DatabaseMetaTest.java
+++ b/core/src/test/java/org/apache/hop/core/database/DatabaseMetaTest.java
@@ -178,6 +178,24 @@ class DatabaseMetaTest {
}
}
+ @Test
+ void quotesCatalogAndSchemaSeparately() {
+ when(iDatabase.getStartQuote()).thenReturn("\"");
+ when(iDatabase.getEndQuote()).thenReturn("\"");
+ when(iDatabase.isSupportsCatalogs()).thenReturn(true);
+ when(iDatabase.getSchemaTableCombination(anyString(), anyString()))
+ .thenAnswer(invocation -> invocation.getArgument(0) + "." +
invocation.getArgument(1));
+
+ assertEquals(
+ "catalog.schema.sample",
+ databaseMeta.getQuotedSchemaTableCombination(variables,
"catalog.schema", "sample"));
+
+ when(iDatabase.isQuoteAllFields()).thenReturn(true);
+ assertEquals(
+ "\"catalog\".\"schema\".\"sample\"",
+ databaseMeta.getQuotedSchemaTableCombination(variables,
"catalog.schema", "sample"));
+ }
+
@Test
@SuppressWarnings("unchecked")
void testModifyingName() {