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 2022/01/29 05:53:06 UTC

[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #15176: Optimize error messages when inline algorithm expression and sharding column not match.

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
##########
@@ -67,7 +68,7 @@ private boolean isAllowRangeQuery() {
     public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Comparable<?>> shardingValue) {
         Closure<?> closure = createClosure();
         closure.setProperty(shardingValue.getColumnName(), shardingValue.getValue());
-        return closure.call().toString();
+        return getTargetShardingNode(closure, shardingValue.getColumnName());

Review comment:
       @zjcnb Can we add some unit test for this logic?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
##########
@@ -84,6 +85,14 @@ public String doSharding(final Collection<String> availableTargetNames, final Pr
         return result;
     }
     
+    private String getTargetShardingNode(final Closure<?> closure, final String columnName) {
+        try {
+            return closure.call().toString();

Review comment:
       @zjcnb Maybe we should consider `MissingMethodException` together.




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