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/09/17 11:35:36 UTC

[GitHub] [shardingsphere] strongduanmu opened a new issue #12528: Wrong sql rewrite when user does not config KeyGenerateStrategy

strongduanmu opened a new issue #12528:
URL: https://github.com/apache/shardingsphere/issues/12528


   ### Which version of ShardingSphere did you use?
   
   master branch
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   proxy or jdbc
   
   ### Expected behavior
   
   execute successfully
   
   ### Actual behavior
   
   Throw exception because wrong sql rewrite and user does not config KeyGenerateStrategy.
   
   ![image](https://user-images.githubusercontent.com/10829171/133775543-984b984a-2dd9-4183-a72e-eb2486c41085.png)
   
   ### Reason analyze (If you can)
   
   Because DialectTableMetaDataLoader loaded the original information of the table, and did not process the generated attribute, a logical error occurred when judging whether to generate a distributed primary key.
   
   ```java
   /**
    * Generated key insert column token generator.
    */
   public final class GeneratedKeyInsertColumnTokenGenerator extends BaseGeneratedKeyTokenGenerator {
       
       @Override
       protected boolean isGenerateSQLToken(final InsertStatementContext insertStatementContext) {
           Optional<InsertColumnsSegment> sqlSegment = insertStatementContext.getSqlStatement().getInsertColumns();
           return sqlSegment.isPresent() && !sqlSegment.get().getColumns().isEmpty()
                   && insertStatementContext.getGeneratedKeyContext().isPresent()
                   && !insertStatementContext.getGeneratedKeyContext().get().getGeneratedValues().isEmpty();
       }
   ...
   }
   ```
   


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



[GitHub] [shardingsphere] tristaZero closed issue #12528: Wrong sql rewrite when user does not config KeyGenerateStrategy

Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #12528:
URL: https://github.com/apache/shardingsphere/issues/12528


   


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