jinyingone opened a new issue, #34153:
URL: https://github.com/apache/shardingsphere/issues/34153

   
   ## sharding version 4.1.1
   ## mybatis version 3.5.3
   
   ## table example:
   
   ```sql
   table:
   
   CREATE TABLE `t1` (
     `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
     `col1` varchar(32) ,
     `col2` varchar(32) ,
     `col3` smallint(6) ,
     `col4` varchar(32)  
   ) ;
   
   sql:
   SELECT * FROM `t1` WHERE `col1` = ? LIMIT ?
   ```
   
   ## Problem Description
   
   During the running process of the program, a column named col1_1 is added 
between col1 and col2. When executing the SELECT * statement, the data of the 
col4 column cannot be retrieved.
   
   The return value of metaData.getColumnCount() is one less.
   
   
   ## Problematic Code
   
   ```java
   ResultSetWrapper
   public ResultSetWrapper(ResultSet rs, Configuration configuration) throws 
SQLException {
       super();
       this.typeHandlerRegistry = configuration.getTypeHandlerRegistry();
       this.resultSet = rs;
       final ResultSetMetaData metaData = rs.getMetaData();
       final int columnCount = metaData.getColumnCount();
       for (int i = 1; i <= columnCount; i++) {
         columnNames.add(configuration.isUseColumnLabel() ? 
metaData.getColumnLabel(i) : metaData.getColumnName(i));
         jdbcTypes.add(JdbcType.forCode(metaData.getColumnType(i)));
         classNames.add(metaData.getColumnClassName(i));
       }
     }
   
   ShardingResultSetMetaData
   public int getColumnCount() {
       return sqlStatementContext instanceof SelectStatementContext ? 
((SelectStatementContext) 
sqlStatementContext).getProjectionsContext().getExpandProjections().size() : 0;
   }
   ```


-- 
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: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to