funky-eyes commented on code in PR #6348:
URL: https://github.com/apache/incubator-seata/pull/6348#discussion_r2190342670


##########
sqlparser/seata-sqlparser-druid/src/main/java/org/apache/seata/sqlparser/druid/BaseRecognizer.java:
##########
@@ -149,4 +157,62 @@ public boolean visit(SQLInsertStatement x) {
         getAst().accept(visitor);
         return true;
     }
+
+    public List<String> getWhereColumns(SQLExpr sqlExpr) {
+        if (sqlExpr == null) {
+            return Collections.emptyList();
+        }
+        // single condition
+        if (sqlExpr instanceof SQLBinaryOpExpr) {
+            return getWhereColumns(Collections.singletonList(sqlExpr));
+        } else {
+            // multiple conditions
+            return getWhereColumns(sqlExpr.getChildren());
+        }
+    }
+
+    public List<String> getWhereColumns(List<SQLObject> list) {
+        if (CollectionUtils.isNotEmpty(list)) {
+            List<String> columns = new ArrayList<>(list.size());
+            for (SQLObject sqlObject : list) {
+                if (sqlObject instanceof SQLIdentifierExpr) {
+                    columns.add(((SQLIdentifierExpr) sqlObject).getName());
+                } else {
+                    getWhereColumns(sqlObject, columns);
+                }
+            }
+            return columns;
+        }
+        return Collections.emptyList();
+    }
+
+    public void getWhereColumns(SQLObject sqlExpr, List<String> list) {
+        if (sqlExpr instanceof SQLBinaryOpExpr) {
+            SQLExpr left = ((SQLBinaryOpExpr) sqlExpr).getLeft();
+            getWhereColumn(left, list);
+            SQLExpr right = ((SQLBinaryOpExpr) sqlExpr).getRight();
+            getWhereColumn(right, list);
+        }
+    }
+
+    public void getWhereColumn(SQLExpr left, List<String> list) {
+        if (left instanceof SQLBetweenExpr) {
+            SQLExpr expr = ((SQLBetweenExpr) left).getTestExpr();
+            if (expr instanceof SQLIdentifierExpr) {
+                list.add(((SQLIdentifierExpr) expr).getName());
+            }
+            if (expr instanceof SQLPropertyExpr) {
+                list.add(((SQLPropertyExpr) expr).getName());
+            }
+        } else if (left instanceof SQLIdentifierExpr) {
+            list.add(((SQLIdentifierExpr) left).getName());

Review Comment:
   Currently, JSON columns are not supported, so we won't consider adding this 
condition directly for now.
   
   



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