ResilientSZUer commented on code in PR #874:
URL: 
https://github.com/apache/incubator-seata-go/pull/874#discussion_r2280211096


##########
pkg/datasource/sql/datasource/utils.go:
##########
@@ -90,7 +90,10 @@ func GetScanSlice(types []*sql.ColumnType) []interface{} {
                        scanSlice = append(scanSlice, &scanVal)
                case ScanTypeUnknown:
                        scanVal := new(interface{})
-                       scanSlice = append(scanSlice, &scanVal)
+                       scanSlice = append(scanSlice, scanVal)

Review Comment:
   Hi, as you suggested, I have added a new unit test for this fix, located at 
pkg/datasource/sql/datasource/utils_test.go. The main idea of this unit test is 
as follows:
   It uses sqlmock to precisely simulate a query result that contains a wide 
variety of  column types, without relying on any real database connection. The 
core purpose of this test is to verify that the fixed GetScanSlice function can 
correctly handle all column types and return a slice with a length that exactly 
matches the number of input columns.
   As the screenshot below shows, the original code fails to pass this new unit 
test because it cannot handle all types correctly, resulting in a slice length 
mismatch:
   <img width="1818" height="1080" alt="image" 
src="https://github.com/user-attachments/assets/a0b722bc-d460-4daf-bba4-88e0d638d4f2";
 />
   And with my fix applied, the code now successfully passes this comprehensive 
unit test, which proves the fix is correct:
   <img width="1821" height="1078" alt="image" 
src="https://github.com/user-attachments/assets/72d12533-9b54-4264-9d7a-4c7b291017cb";
 />
   
   
   



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