TaoZhiMLND edited a comment on issue #5421:
URL: https://github.com/apache/shardingsphere/issues/5421#issuecomment-623866759


   Now the test turn into green.
   changes are as follows,
   1、modify ColumnMetaDataLoade#generateEmptyResultSQL 
   ```java
   return "SELECT * FROM " + delimiterLeft + table + delimiterRight + " WHERE 1 
!= 1" 
   ```
   (remove semicolons behind WHERE 1 != 1 which  not allowed in oracle)
   2、return value of connection.getMetaData().getIndexInfo includes a null name 
record ~~most times but not(I have some mistakes)~~ always . So 
IndexMetaDataLoader#load needs a check for whether indexName is null. 
   ```java
       public static Collection<IndexMetaData> load(final Connection 
connection, final String table) throws SQLException {
           Collection<IndexMetaData> result = new HashSet<>();
           try (ResultSet resultSet = 
connection.getMetaData().getIndexInfo(connection.getCatalog(), 
connection.getSchema(), table, false, false)) {
               while (resultSet.next()) {
                   String indexName = resultSet.getString(INDEX_NAME);
                   if (Strings.isNullOrEmpty(indexName)) {
                       continue;
                   }
                   result.add(new IndexMetaData(indexName));
               }
           }
           return result;
       }
   ```
   3、connection.getMetaData().getColumns in ColumnMetaDataLoader#load need 
specify a schema, otherwise it will return duplicated columns, so that I use 
connection.getSchema() replace null.
   ```java
           try (ResultSet resultSet = 
connection.getMetaData().getColumns(connection.getCatalog(), 
connection.getSchema(), table, "%")) {
               while (resultSet.next()) {
                   String columnName = resultSet.getString(COLUMN_NAME);
                   columnTypes.add(resultSet.getInt(DATA_TYPE));
                   columnTypeNames.add(resultSet.getString(TYPE_NAME));
                   isPrimaryKeys.add(primaryKeys.contains(columnName));
                   columnNames.add(columnName);
               }
           }
   ```
   it is works to me. Can we discuss further how to modify it?


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


Reply via email to