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 2020/04/28 08:15:11 UTC

[GitHub] [shardingsphere] XZhi edited a comment on issue #5210: ON DUPLICATE KEY UPDATE Sub-Clause paramter dropped

XZhi edited a comment on issue #5210:
URL: https://github.com/apache/shardingsphere/issues/5210#issuecomment-620452376


   @kimmking hi I got the same issue, but a little difference is  that the insert into clause contains two placeholders `#{item.receivedCount,jdbcType=INTEGER} + #{item.baseCount,jdbcType=INTEGER}` at values segment.    The code is as below:
   
   `
   <insert id="batchInsertOrUpdate" parameterType="xxx.UserTemplateStat">
           INSERT INTO user_template_stat (
           coupon_template_id,
           user_id,
           channel_code,
           received_count
           )
           VALUES
           <foreach collection="userTemplateStats" item="item" separator=",">
               (
               #{item.couponTemplateId,jdbcType=INTEGER},
               #{item.userId,jdbcType=VARCHAR},
               <choose>
                   <when test="item.channelCode != null">
                       #{item.channelCode,jdbcType=VARCHAR},
                   </when>
                   <otherwise>
                       '',
                   </otherwise>
               </choose>
               #{item.receivedCount,jdbcType=INTEGER} + #{item.baseCount,jdbcType=INTEGER}
               )
           </foreach>
           ON DUPLICATE KEY UPDATE
           <trim suffixOverrides=",">
               received_count = received_count + VALUES(received_count)
           </trim>
       </insert>
   `
   ![image](https://user-images.githubusercontent.com/4264938/80463783-60659f00-896b-11ea-8f2c-b93c1d8b21ef.png)
   
   
   After the sql rewrite, there are 2 parameters(4 parameters before rewrite) and  the parameters for ` #{item.receivedCount,jdbcType=INTEGER} + #{item.baseCount,jdbcType=INTEGER}` are parsed incorrectly.  Here is debug information for InsertValueContext, the CommonExpressonSegment is not a  ParameterMarkerExpressionSegment.
   
   ![image](https://user-images.githubusercontent.com/4264938/80462638-92760180-8969-11ea-8692-e65fd59a5d00.png)
   
   


----------------------------------------------------------------
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:
users@infra.apache.org