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/09/16 02:53:22 UTC

[GitHub] [shardingsphere] tristaZero commented on a change in pull request #7469: refactor CallStatement, DeleteStatement and DoStatement in DMLStatement

tristaZero commented on a change in pull request #7469:
URL: https://github.com/apache/shardingsphere/pull/7469#discussion_r489126477



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidator.java
##########
@@ -42,7 +44,7 @@ public void preValidate(final ShardingRule shardingRule, final RouteContext rout
     
     @Override
     public void postValidate(final DeleteStatement sqlStatement, final RouteResult routeResult) {
-        if (sqlStatement.getLimit().isPresent() && routeResult.getRouteUnits().size() > 1) {
+        if (sqlStatement instanceof MySQLStatement && ((MySQLDeleteStatement) sqlStatement).getLimit().isPresent() && routeResult.getRouteUnits().size() > 1) {

Review comment:
       Extracting a function is better.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dml/impl/DeleteStatementAssert.java
##########
@@ -49,8 +51,10 @@
     public static void assertIs(final SQLCaseAssertContext assertContext, final DeleteStatement actual, final DeleteStatementTestCase expected) {
         assertTable(assertContext, actual, expected);
         assertWhereClause(assertContext, actual, expected);
-        assertOrderByClause(assertContext, actual, expected);
-        assertLimitClause(assertContext, actual, expected);
+        if (actual instanceof MySQLStatement) {
+            assertOrderByClause(assertContext, (MySQLDeleteStatement) actual, expected);
+            assertLimitClause(assertContext, (MySQLDeleteStatement) actual, expected);    
+        }

Review comment:
       How about to extract A function named `assertXXXXX`

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dml/impl/DeleteStatementAssert.java
##########
@@ -49,8 +51,10 @@
     public static void assertIs(final SQLCaseAssertContext assertContext, final DeleteStatement actual, final DeleteStatementTestCase expected) {
         assertTable(assertContext, actual, expected);
         assertWhereClause(assertContext, actual, expected);
-        assertOrderByClause(assertContext, actual, expected);
-        assertLimitClause(assertContext, actual, expected);
+        if (actual instanceof MySQLStatement) {
+            assertOrderByClause(assertContext, (MySQLDeleteStatement) actual, expected);
+            assertLimitClause(assertContext, (MySQLDeleteStatement) actual, expected);    
+        }

Review comment:
       It is an optional item. Just from my glance, my feeling is that it is better to gather this judgment and handling detail into a function. 




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