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/05/27 03:37:22 UTC

[GitHub] [shardingsphere] LightShine opened a new issue #5806: ShardingUpdateStatementValidator requires that the value of the sharding key in set-statement must be consistent with the where-statement

LightShine opened a new issue #5806:
URL: https://github.com/apache/shardingsphere/issues/5806


   - config
   ```
   spring.shardingsphere.sharding.tables.plus_user.database-strategy.complex.sharding-columns=user_phone,user_id
   ```
   - sql 
   ```
    <update id="updateByUserId" parameterType="com.cmcc.hy.plus.common.domain.PlusUser">
           update plus_user
           <set>
               <if test="familyId != null">
                   family_id = #{familyId,jdbcType=VARCHAR},
               </if>
               <if test="userName != null">
                   user_name = #{userName,jdbcType=VARCHAR},
               </if>
               <if test="userPhone != null">
                   user_phone = #{userPhone,jdbcType=VARCHAR},
               </if>
               <if test="mobileOperator != null">
                   mobile_operator = #{mobileOperator,jdbcType=BIT},
               </if>
               <if test="province != null">
                   province = #{province,jdbcType=VARCHAR},
               </if>
               <if test="userType != null">
                   user_type = #{userType,jdbcType=BIT},
               </if>
               <if test="userOrigin != null">
                   user_origin = #{userOrigin,jdbcType=BIT},
               </if>
               <if test="userAvatar != null">
                   user_avatar = #{userAvatar,jdbcType=VARCHAR},
               </if>
               <if test="nickName != null">
                   nick_name = #{nickName,jdbcType=VARCHAR},
               </if>
               <if test="userStatus != null">
                   user_status = #{userStatus},
               </if>
               <if test="familyJoinTime != null">
                   family_join_time = #{familyJoinTime,jdbcType=TIMESTAMP},
               </if>
               <if test="isDeleted != null">
                   is_deleted = #{isDeleted,jdbcType=BIT},
               </if>
           </set>
           where user_id = #{userId,jdbcType=VARCHAR}
       </update>
   ```
   - enviroment
   mysql, mybatis
   
   -exception
   ### Cause: org.apache.shardingsphere.underlying.common.exception.ShardingSphereException: Can not update sharding key, logic table: [plus_user], column: [org.apache.shardingsphere.sql.parser.sql.segment.dml.assignment.AssignmentSegment@3afb90e5].
   
   This means that only PreciseShardingAlgorithm can perform update statement sharding?
   


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



[GitHub] [shardingsphere] LightShine commented on issue #5806: ShardingUpdateStatementValidator requires that the value of the sharding key in set-statement must be consistent with the where-statement

Posted by GitBox <gi...@apache.org>.
LightShine commented on issue #5806:
URL: https://github.com/apache/shardingsphere/issues/5806#issuecomment-685212223


   > Does this mean the ShardingUpdateStatementValidator.preValidate should let sql whose where segment contains only partial of the sharding-columns pass?
   
   Yes, I think this can be more flexible.


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



[GitHub] [shardingsphere] LightShine commented on issue #5806: ShardingUpdateStatementValidator requires that the value of the sharding key in set-statement must be consistent with the where-statement

Posted by GitBox <gi...@apache.org>.
LightShine commented on issue #5806:
URL: https://github.com/apache/shardingsphere/issues/5806#issuecomment-634357621


   > what is your version?
   
   4.1.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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] victorzhangchn commented on issue #5806: ShardingUpdateStatementValidator requires that the value of the sharding key in set-statement must be consistent with the where-statement

Posted by GitBox <gi...@apache.org>.
victorzhangchn commented on issue #5806:
URL: https://github.com/apache/shardingsphere/issues/5806#issuecomment-683545414


   Does this mean the ShardingUpdateStatementValidator.preValidate should let sql whose where segment contains only partial of the sharding-columns pass?


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



[GitHub] [shardingsphere] LightShine commented on issue #5806: ShardingUpdateStatementValidator requires that the value of the sharding key in set-statement must be consistent with the where-statement

Posted by GitBox <gi...@apache.org>.
LightShine commented on issue #5806:
URL: https://github.com/apache/shardingsphere/issues/5806#issuecomment-946404369


   > Looks master branch has the same logic:
   > 
   > ```
   > throw new ShardingSphereException("Can not update sharding key, logic table: [%s], column: [%s].", tableName, shardingColumn);
   > ```
   > 
   > @LightShine , could we just shard by `user_id`? Since `user_phone` is sharding column, if it's changeable, it'll cause data record redistribution.
   
   no. In our scenario, user_id and user_phone need to be used for sharding. Moreover, my problem is that the update sql should not determine the existence of the sharding key in the set-statament.


-- 
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] victorzhangchn commented on issue #5806: ShardingUpdateStatementValidator requires that the value of the sharding key in set-statement must be consistent with the where-statement

Posted by GitBox <gi...@apache.org>.
victorzhangchn commented on issue #5806:
URL: https://github.com/apache/shardingsphere/issues/5806#issuecomment-687038800


   > > Does this mean the ShardingUpdateStatementValidator.preValidate should let sql whose where segment contains only partial of the sharding-columns pass?
   > 
   > Yes, I think this can be more flexible.
   
   @terrymanu Because that I am a newbie for the community, and my thought may be limitted lacking of overall understanding of the project, so I want to ask you for suggestion: Do you think this resquest is resonable?


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



[GitHub] [shardingsphere] terrymanu commented on issue #5806: ShardingUpdateStatementValidator requires that the value of the sharding key in set-statement must be consistent with the where-statement

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #5806:
URL: https://github.com/apache/shardingsphere/issues/5806#issuecomment-634123748


   what is your version?


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



[GitHub] [shardingsphere] sandynz commented on issue #5806: ShardingUpdateStatementValidator requires that the value of the sharding key in set-statement must be consistent with the where-statement

Posted by GitBox <gi...@apache.org>.
sandynz commented on issue #5806:
URL: https://github.com/apache/shardingsphere/issues/5806#issuecomment-943168856


   Looks master branch has the same logic:
   ```
   throw new ShardingSphereException("Can not update sharding key, logic table: [%s], column: [%s].", tableName, shardingColumn);
   ```
   
   @LightShine , could we just shard by `user_id`?
   Since `user_phone` is sharding column, if it's changeable, it'll cause data record redistribution.
   


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