Copilot commented on code in PR #927:
URL: 
https://github.com/apache/incubator-seata-go/pull/927#discussion_r2394876877


##########
pkg/datasource/sql/undo/builder/mysql_insert_undo_log_builder.go:
##########
@@ -241,8 +241,13 @@ func (u *MySQLInsertUndoLogBuilder) getPkIndex(InsertStmt 
*ast.InsertStmt, meta
        if len(meta.Columns) > 0 {
                for paramIdx := 0; paramIdx < insertColumnsSize; paramIdx++ {
                        sqlColumnName := InsertStmt.Columns[paramIdx].Name.O
-                       if u.containPK(sqlColumnName, meta) {
-                               pkIndexMap[sqlColumnName] = paramIdx
+                       normalizedColumnName := 
executor.DelEscape(sqlColumnName, types.DBTypeMySQL)

Review Comment:
   The reference to `executor.DelEscape` appears incorrect. Based on the 
context and the similar fix in insert_executor.go which uses `DelEscape` 
directly, this should likely be `DelEscape(sqlColumnName, types.DBTypeMySQL)` 
without the `executor.` prefix.



##########
pkg/datasource/sql/undo/builder/mysql_insert_undo_log_builder.go:
##########
@@ -241,8 +241,13 @@ func (u *MySQLInsertUndoLogBuilder) getPkIndex(InsertStmt 
*ast.InsertStmt, meta
        if len(meta.Columns) > 0 {
                for paramIdx := 0; paramIdx < insertColumnsSize; paramIdx++ {
                        sqlColumnName := InsertStmt.Columns[paramIdx].Name.O
-                       if u.containPK(sqlColumnName, meta) {
-                               pkIndexMap[sqlColumnName] = paramIdx
+                       normalizedColumnName := 
executor.DelEscape(sqlColumnName, types.DBTypeMySQL)
+                       pkColumnNameList := meta.GetPrimaryKeyOnlyName()
+                       for _, pkName := range pkColumnNameList {
+                               if strings.EqualFold(pkName, 
normalizedColumnName) {
+                                       pkIndexMap[pkName] = paramIdx
+                                       break
+                               }
                        }

Review Comment:
   This code removes the original logic that checked 
`u.containPK(sqlColumnName, meta)` but doesn't handle the case where there are 
no primary key columns. The original code had a safety check through the 
`containPK` method, but this new implementation assumes primary keys exist. 
Consider adding a check to ensure `pkColumnNameList` is not empty before 
processing.



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