arjansh commented on a change in pull request #227: MM-1219 Returning schemas 
SQL Server
URL: https://github.com/apache/metamodel/pull/227#discussion_r320159907
 
 

 ##########
 File path: jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
 ##########
 @@ -778,18 +780,33 @@ private String findDefaultSchema(final String 
defaultName, final List<String> sc
      * @throws SQLException
      */
     private Set<String> getSchemaSQLServerNames(DatabaseMetaData metaData) 
throws SQLException {
-        // Distinct schema names. metaData.getTables() is a denormalized
-        // resultset
-        Set<String> schemas = new HashSet<>();
-        ResultSet rs = null;
+        // Distinct schema names. metaData.getTables() is a denormalized 
resultset
+        final Set<String> schemas = new HashSet<>();
+        ResultSet resultSet = null;
+
+        // Find DBO schema if present
         try {
 
 Review comment:
   The added piece of code essentially checks if the default SQL server schema 
is available, and if so adds it to the schema, then it executes the already 
existing logic. For understand-ability of the code it might be better to 
extract the logic which checks if the default SQL server schema is available 
into a separate method, e.g. 
   
   ```
       if (hasDefaultSQLServerSchema(metaData) {
           schemas.add(DEFAULT_SCHEMA_NAME_SQLSERVER);
       }
   ```
   
   and
   
   ```
       private boolean hasDefaultSQLServerSchema(final DatabaseMetaData 
metaData) throws SQLException {
           try (ResultSet schemas = metaData.getSchemas()) {
               while (schemas.next()) {
                   if 
(schemas.getString("TABLE_SCHEM").equals(DEFAULT_SCHEMA_NAME_SQLSERVER)) {
                       return true;
                   }
               }
           }
           return false;
       }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to