You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/08/08 04:12:35 UTC

[GitHub] [shardingsphere] terrymanu commented on a change in pull request #11699: Schema name add default value

terrymanu commented on a change in pull request #11699:
URL: https://github.com/apache/shardingsphere/pull/11699#discussion_r684711248



##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/api/ShardingSphereDataSourceFactory.java
##########
@@ -76,7 +76,7 @@ public static DataSource createDataSource(final Map<String, DataSource> dataSour
      * @throws SQLException SQL exception
      */
     public static DataSource createDataSource(final String schemaName, final DataSource dataSource, final Collection<RuleConfiguration> configs, final Properties props) throws SQLException {
-        return createDataSource(schemaName, Collections.singletonMap(schemaName, dataSource), configs, props);
+        return createDataSource(schemaName, Collections.singletonMap(Strings.isNullOrEmpty(schemaName) ? DefaultSchema.LOGIC_NAME : schemaName, dataSource), configs, props);

Review comment:
       The inline method `createDataSource` has already check null of schemaName, is it necessary to add check again?

##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/datasource.xsd
##########
@@ -29,7 +29,7 @@
                 <xsd:element ref="beans:props" minOccurs="0" />
             </xsd:all>
             <xsd:attribute name="id" type="xsd:string" use="required" />
-            <xsd:attribute name="schema-name" type="xsd:string" />
+            <xsd:attribute name="schema-name" type="xsd:string" default="logic_db"/>

Review comment:
       Please keep one space between `"logic_db"` and `/>`, just keep consist with others

##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/schema/SchemaNameSetter.java
##########
@@ -40,6 +42,10 @@
      */
     public static String getSchemaName(final Environment environment) {
         StandardEnvironment standardEnv = (StandardEnvironment) environment;
-        return standardEnv.getProperty(PREFIX + SCHEMA_NAME);
+        String schemaName = standardEnv.getProperty(PREFIX + SCHEMA_NAME);
+        if (StringUtils.isEmpty(schemaName)) {
+            return DefaultSchema.LOGIC_NAME;
+        }
+        return schemaName;

Review comment:
       The return value should name as `result`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org