WangzJi commented on code in PR #7456:
URL: https://github.com/apache/incubator-seata/pull/7456#discussion_r2158442305


##########
sqlparser/seata-sqlparser-druid/src/main/java/org/apache/seata/sqlparser/druid/DruidSQLRecognizerFactoryImpl.java:
##########
@@ -38,42 +38,47 @@
 class DruidSQLRecognizerFactoryImpl implements SQLRecognizerFactory {
     @Override
     public List<SQLRecognizer> create(String sql, String dbType) {
-        List<SQLStatement> asts = SQLUtils.parseStatements(sql, 
DruidDbTypeAdapter.getAdaptiveDbType(dbType));
-        if (CollectionUtils.isEmpty(asts)) {
-            throw new UnsupportedOperationException("Unsupported SQL: " + sql);
-        }
-        if (asts.size() > 1 && !(asts.stream().allMatch(statement -> statement 
instanceof SQLUpdateStatement)
-                || asts.stream().allMatch(statement -> statement instanceof 
SQLDeleteStatement))) {
-            throw new UnsupportedOperationException("ONLY SUPPORT SAME TYPE 
(UPDATE OR DELETE) MULTI SQL -" + sql);
-        }
         List<SQLRecognizer> recognizers = null;
         SQLRecognizer recognizer = null;
-        for (SQLStatement ast : asts) {
-            SQLOperateRecognizerHolder recognizerHolder =
-                    
SQLOperateRecognizerHolderFactory.getSQLRecognizerHolder(dbType.toLowerCase());
-            if (ast instanceof SQLInsertStatement) {
-                recognizer = recognizerHolder.getInsertRecognizer(sql, ast);
-            } else if (ast instanceof SQLUpdateStatement) {
-                recognizer = recognizerHolder.getUpdateRecognizer(sql, ast);
-            } else if (ast instanceof SQLDeleteStatement) {
-                recognizer = recognizerHolder.getDeleteRecognizer(sql, ast);
-            } else if (ast instanceof SQLSelectStatement) {
-                recognizer = 
recognizerHolder.getSelectForUpdateRecognizer(sql, ast);
+        try {
+            List<SQLStatement> asts = SQLUtils.parseStatements(sql, 
DruidDbTypeAdapter.getAdaptiveDbType(dbType));

Review Comment:
   Looks good! Just a suggestion — perhaps we could replace `asts` with 
something more descriptive like `sqlStatements` or `parsedStatements` for 
better readability. Avoiding abbreviations in variable names can help with 
clarity in the long run. What do you think?



-- 
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-unsubscr...@seata.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to