sunday20111107 opened a new issue #9446:
URL: https://github.com/apache/shardingsphere/issues/9446


   Caused by: java.lang.ClassCastException: 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ExpressionProjectionSegment
 cannot be cast to 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment
   at 
org.apache.shardingsphere.infra.binder.segment.insert.values.OnDuplicateUpdateContext.getValue(OnDuplicateUpdateContext.java:87)
 ~[shardingsphere-infra-binder-5.0.0-alpha.jar:5.0.0-alpha]
   at 
org.apache.shardingsphere.encrypt.rewrite.parameter.impl.EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.lambda$rewrite$0(EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java:59)
 ~[shardingsphere-encrypt-rewrite-5.0.0-alpha.jar:5.0.0-alpha]
   at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_73]
   at 
org.apache.shardingsphere.encrypt.rewrite.parameter.impl.EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.rewrite(EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java:58)
 ~[shardingsphere-encrypt-rewrite-5.0.0-alpha.jar:5.0.0-alpha]
   at
   
   ### Which version of ShardingSphere did you use?
   shardingsphere-jdbc:5.0.0-alpha
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   
   ### Actual behavior
   Caused by: java.lang.ClassCastException: 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ExpressionProjectionSegment
 cannot be cast to 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment
   ### Reason analyze (If you can)
   1. as follows sql, when i config 'name' use ENCRYPT, my sql like 'ON 
DUPLICATE KEY UPDATE name=VALUES(name)' will throw As above exception, but i 
change the sql like this 'ON DUPLICATE KEY UPDATE name=?', ENCRYPT is work good.
   2. i trace the code, find ENCRYPT field will use OnDuplicateUpdateContext 
       public Object getValue(final int index) {
           ExpressionSegment valueExpression = valueExpressions.get(index);
           return valueExpression instanceof ParameterMarkerExpressionSegment ? 
parameters.get(getParameterIndex(valueExpression)) : 
((LiteralExpressionSegment) valueExpression).getLiterals();
       }
   3. when name=VALUES(name) valueExpression will is 
ExpressionProjectionSegment,  is not LiteralExpressionSegment so will throw as 
above exception.
   4. when name=? valueExpression will is ParameterMarkerExpressionSegment ,  
is work good.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   INSERT INTO anchor_info (id, source, anchorId, name, avatar, status, 
createTime, updateTime) VALUES
   (#{id,jdbcType=BIGINT}, #{source,jdbcType=VARCHAR}, 
#{anchorId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
   #{avatar,jdbcType=VARCHAR},#{status,jdbcType=TINYINT}, 
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT})
   ON DUPLICATE KEY UPDATE name=VALUES(name),
   updateTime=VALUES(updateTime);
   
   rules:
   
   !ENCRYPT
   tables:
   anchor_info:
   columns:
   name:
   cipherColumn: name
   encryptorName: aes
   encryptors:
   aes:
   type: AES
   props:
   aes-key-value: abcdisjckel14003c2f8ea32cc1d59e5
   
   ### Example codes for reproduce this issue (such as a github link).
   


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