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

 ##########
 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 {
-            rs = metaData.getTables(_catalogName, null, null, 
JdbcUtils.getTableTypesAsStrings(_tableTypes));
-            while (rs.next()) {
-                schemas.add(rs.getString("TABLE_SCHEM"));
+            resultSet = metaData.getSchemas();
+            while (resultSet.next()) {
+                if 
(resultSet.getString("TABLE_SCHEM").equals(DEFAULT_SCHEMA_NAME_SQLSERVER)) {
 
 Review comment:
   The String `"TABLE_SCHEM"` is used twice now in the changed code, can you 
extract it into a constant?

----------------------------------------------------------------
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