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

zhangliang 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 5649f6206c1 refactor(infra): optimize schema names loading logic 
(#35305)
5649f6206c1 is described below

commit 5649f6206c15ad79f43267d7ff02c5f8b27b66d8
Author: Liang Zhang <zhangli...@apache.org>
AuthorDate: Thu May 1 13:09:56 2025 +0800

    refactor(infra): optimize schema names loading logic (#35305)
    
    - Extract DialectSchemaOption to a separate variable for better readability
    - Simplify the condition to check for default schema presence
---
 .../core/metadata/data/loader/type/SchemaMetaDataLoader.java         | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/data/loader/type/SchemaMetaDataLoader.java
 
b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/data/loader/type/SchemaMetaDataLoader.java
index d8a9e0036cd..3eff99f9e7c 100644
--- 
a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/data/loader/type/SchemaMetaDataLoader.java
+++ 
b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/data/loader/type/SchemaMetaDataLoader.java
@@ -23,6 +23,7 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import 
org.apache.shardingsphere.infra.database.core.metadata.data.loader.MetaDataLoaderConnection;
 import 
org.apache.shardingsphere.infra.database.core.metadata.database.metadata.DialectDatabaseMetaData;
+import 
org.apache.shardingsphere.infra.database.core.metadata.database.metadata.option.schema.DialectSchemaOption;
 import 
org.apache.shardingsphere.infra.database.core.metadata.database.system.SystemDatabase;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
@@ -89,8 +90,8 @@ public final class SchemaMetaDataLoader {
      * @throws SQLException SQL exception
      */
     public static Collection<String> loadSchemaNames(final Connection 
connection, final DatabaseType databaseType) throws SQLException {
-        DialectDatabaseMetaData dialectDatabaseMetaData = new 
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData();
-        if 
(!dialectDatabaseMetaData.getSchemaOption().getDefaultSchema().isPresent()) {
+        DialectSchemaOption schemaOption = new 
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getSchemaOption();
+        if (!schemaOption.getDefaultSchema().isPresent()) {
             return Collections.singletonList(connection.getSchema());
         }
         Collection<String> result = new LinkedList<>();

Reply via email to