Copilot commented on code in PR #7675:
URL: https://github.com/apache/incubator-seata/pull/7675#discussion_r2438437041


##########
sqlparser/seata-sqlparser-druid/src/test/java/org/apache/seata/sqlparser/druid/DruidSQLRecognizerFactoryTest.java:
##########
@@ -208,4 +220,44 @@ public void testIsSqlSyntaxSupports() {
         Assertions.assertThrows(
                 NotSupportYetException.class, () -> 
recognizerFactory.create(sql9, JdbcConstants.KINGBASE));
     }
+
+    @Test
+    public void testInsertFirstNotSupported() {
+        SQLRecognizerFactory recognizerFactory =
+                EnhancedServiceLoader.load(SQLRecognizerFactory.class, 
SqlParserType.SQL_PARSER_TYPE_DRUID);
+        // Test that INSERT FIRST syntax should be rejected at the Factory 
level
+        String sql = "INSERT FIRST "
+                + "WHEN salary > 1000 THEN INTO high_earners (id, name, 
salary) VALUES (1, 'John', 2000) "
+                + "WHEN salary <= 1000 THEN INTO low_earners (id, name, 
salary) VALUES (1, 'John', 800) "
+                + "SELECT 1 FROM DUAL";
+
+        NotSupportYetException exception = Assertions.assertThrows(
+                NotSupportYetException.class, () -> 
recognizerFactory.create(sql, JdbcConstants.ORACLE));
+
+        assertTrue(exception.getMessage().contains("INSERT FIRST not supported 
yet"));
+    }
+
+    @Test
+    void testGetMultiInsertRecognizerDelegation() {
+        // 1.sql
+        String sql = "INSERT ALL INTO a(id) VALUES(1) INTO a(id) VALUES(2) 
SELECT 1 FROM dual";
+
+        SQLStatement stmt = SQLUtils.parseSingleStatement(sql, "oracle");
+        assertTrue(stmt instanceof OracleMultiInsertStatement);
+
+        // 2. mock recognizerHolder and recognizer

Review Comment:
   Comment formatting inconsistency: '1.sql' should be '1. SQL' to match the 
style of '2. mock recognizerHolder and recognizer' and '3. stub 
getMultiInsertRecognizer'.



##########
sqlparser/seata-sqlparser-druid/src/main/java/org/apache/seata/sqlparser/druid/oracle/OracleMultiInsertRecognizer.java:
##########
@@ -0,0 +1,258 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.sqlparser.druid.oracle;
+
+import com.alibaba.druid.sql.ast.SQLExpr;
+import com.alibaba.druid.sql.ast.SQLStatement;
+import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
+import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr;
+import com.alibaba.druid.sql.ast.expr.SQLNullExpr;
+import com.alibaba.druid.sql.ast.expr.SQLSequenceExpr;
+import com.alibaba.druid.sql.ast.expr.SQLValuableExpr;
+import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr;
+import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
+import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
+import 
com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleMultiInsertStatement;
+import com.alibaba.druid.sql.dialect.oracle.visitor.OracleOutputVisitor;
+import org.apache.seata.common.exception.NotSupportYetException;
+import org.apache.seata.common.util.CollectionUtils;
+import org.apache.seata.sqlparser.SQLInsertRecognizer;
+import org.apache.seata.sqlparser.SQLType;
+import org.apache.seata.sqlparser.struct.NotPlaceholderExpr;
+import org.apache.seata.sqlparser.struct.Null;
+import org.apache.seata.sqlparser.struct.SqlMethodExpr;
+import org.apache.seata.sqlparser.struct.SqlSequenceExpr;
+import org.apache.seata.sqlparser.util.ColumnUtils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Oracle Multi Insert Recognizer for INSERT ALL statements
+ */
+public class OracleMultiInsertRecognizer extends BaseOracleRecognizer 
implements SQLInsertRecognizer {
+
+    private final OracleMultiInsertStatement ast;
+    private String validatedTableName;
+    private List<String> validatedColumns;
+
+    public OracleMultiInsertRecognizer(String originalSQL, SQLStatement ast) {
+        super(originalSQL);
+        this.ast = (OracleMultiInsertStatement) ast;
+        validateSingleTableConsistency();
+    }
+
+    /**
+     * Verify that all entries are in the same table and have consistent 
column definitions.

Review Comment:
   The method comment should describe what happens when validation fails 
(throws NotSupportYetException) and clarify that it also initializes 
validatedTableName and validatedColumns.
   ```suggestion
        * Verifies that all entries are in the same table and have consistent 
column definitions.
        * <p>
        * If validation fails (e.g., conditional clauses are present, or 
table/column consistency is violated),
        * this method throws a {@link NotSupportYetException}.
        * <p>
        * Upon successful validation, initializes {@code validatedTableName} 
and {@code validatedColumns}
        * with the consistent table name and column definitions.
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to