strongduanmu commented on a change in pull request #6377:
URL: https://github.com/apache/shardingsphere/pull/6377#discussion_r456852765



##########
File path: 
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidator.java
##########
@@ -35,9 +38,15 @@
     @Override
     public void validate(final ShardingRule shardingRule, final 
InsertStatement sqlStatement, final List<Object> parameters) {
         Optional<OnDuplicateKeyColumnsSegment> onDuplicateKeyColumnsSegment = 
sqlStatement.getOnDuplicateKeyColumns();
-        if (onDuplicateKeyColumnsSegment.isPresent() && 
isUpdateShardingKey(shardingRule, onDuplicateKeyColumnsSegment.get(), 
sqlStatement.getTable().getTableName().getIdentifier().getValue())) {
+        String tableName = 
sqlStatement.getTable().getTableName().getIdentifier().getValue();
+        if (onDuplicateKeyColumnsSegment.isPresent() && 
isUpdateShardingKey(shardingRule, onDuplicateKeyColumnsSegment.get(), 
tableName)) {
             throw new ShardingSphereException("INSERT INTO .... ON DUPLICATE 
KEY UPDATE can not support update for sharding column.");
         }
+        Optional<SubquerySegment> insertSelectSegment = 
sqlStatement.getInsertSelect();
+        if (insertSelectSegment.isPresent() && 
isContainsKeyGenerateStrategy(shardingRule, tableName)
+                && !isContainsKeyGenerateColumn(shardingRule, 
sqlStatement.getColumns(), tableName)) {
+            throw new ShardingSphereException("INSERT INTO .... SELECT can not 
support key generate column.");

Review comment:
       > This exception looks not clear enough, how about `INSERT INTO .... 
SELECT can not support applying keyGenerator to absent generateKeyColumn.` ?
   
   This prompt is better. 👍




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


Reply via email to