This is an automated email from the ASF dual-hosted git repository.

menghaoranss pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 4c428503ac6 Use protocol schema resolver for single table fallback 
(#39707)
4c428503ac6 is described below

commit 4c428503ac659baa5d08244284befcd8b28d943b
Author: Haoran Meng <[email protected]>
AuthorDate: Thu Sep 3 15:33:43 2026 +0800

    Use protocol schema resolver for single table fallback (#39707)
---
 .../single/decorator/SingleRuleConfigurationDecorator.java         | 2 +-
 .../single/decorator/SingleRuleConfigurationDecoratorTest.java     | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecorator.java
 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecorator.java
index 2631598c799..92ec4e46f04 100644
--- 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecorator.java
+++ 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecorator.java
@@ -77,7 +77,7 @@ public final class SingleRuleConfigurationDecorator 
implements RuleConfiguration
             return loadAllTables(isSchemaAvailable, actualDataNodes);
         }
         String defaultSchemaName = dataSources.isEmpty()
-                ? new 
DatabaseTypeRegistry(databaseType).getDefaultSchemaName(databaseName)
+                ? DefaultSchemaNameResolver.resolveProtocol(databaseType, 
databaseName)
                 : DefaultSchemaNameResolver.resolveStorage(databaseType, 
dataSources.values().iterator().next(), databaseName);
         Collection<DataNode> configuredDataNodes = 
SingleTableLoadUtils.convertToDataNodesWithDefaultSchemaName(defaultSchemaName, 
databaseType, splitTables);
         return loadSpecifiedTables(isSchemaAvailable, actualDataNodes, 
builtRules, configuredDataNodes);
diff --git 
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecoratorTest.java
 
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecoratorTest.java
index b4a6990c8ca..529ecf0021d 100644
--- 
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecoratorTest.java
+++ 
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecoratorTest.java
@@ -157,7 +157,11 @@ class SingleRuleConfigurationDecoratorTest {
         Collection<String> splitTables = 
Collections.singleton("*.foo_schema.t_order");
         Collection<DataNode> configuredDataNodes = Collections.singleton(new 
DataNode("foo_ds", "foo_schema", "t_order"));
         when(SingleTableDataNodeLoader.load(anyString(), anyMap(), 
anyCollection(), anyCollection(), anyMap())).thenReturn(actualDataNodes);
-        mockSplitAndConvert(splitTables, configuredDataNodes, 
Collections.emptyList(), Collections.emptyList());
+        
when(SingleTableLoadUtils.splitTableLines(anyCollection())).thenReturn(splitTables);
+        
when(SingleTableLoadUtils.getExcludedTables(anyCollection())).thenReturn(Collections.emptyList());
+        when(DefaultSchemaNameResolver.resolveProtocol(databaseType, 
"foo_db")).thenReturn("foo_schema");
+        
when(SingleTableLoadUtils.convertToDataNodesWithDefaultSchemaName("foo_schema", 
databaseType, splitTables)).thenReturn(configuredDataNodes);
+        
when(SingleTableLoadUtils.getFeatureRequiredSingleTables(anyCollection())).thenReturn(Collections.emptyList());
         SingleRuleConfiguration ruleConfig = new 
SingleRuleConfiguration(Collections.singleton("*.foo_schema.t_order"), null);
         try (MockedConstruction<DatabaseTypeRegistry> ignored = 
mockSchemaRegistry(true)) {
             assertThat(decorator.decorate("foo_db", Collections.emptyMap(), 
Collections.singleton(mock(ShardingSphereRule.class, RETURNS_DEEP_STUBS)), 
ruleConfig).getTables(),
@@ -306,7 +310,6 @@ class SingleRuleConfigurationDecoratorTest {
         DialectDatabaseMetaData dialectDatabaseMetaData = 
mock(DialectDatabaseMetaData.class, RETURNS_DEEP_STUBS);
         
when(dialectDatabaseMetaData.getSchemaOption().isSchemaAvailable()).thenReturn(schemaAvailable);
         return mockConstruction(DatabaseTypeRegistry.class, (mock, context) -> 
{
-            when(mock.getDefaultSchemaName(anyString())).thenAnswer(invocation 
-> invocation.getArgument(0));
             
when(mock.getDialectDatabaseMetaData()).thenReturn(dialectDatabaseMetaData);
         });
     }

Reply via email to