@@ -707,18 +707,19 @@ func TestSqlcmdPrefersSharedMemoryProtocol(t *testing.T) {
707707}
708708
709709// TestSafeColumnTypesHandlesPanic verifies that safeColumnTypes properly catches
710- // panics from the underlying driver and converts them to errors
710+ // panics from the underlying driver and converts them to errors.
711+ //
712+ // This test validates the panic recovery mechanism by triggering a panic with a
713+ // nil Rows pointer. While this doesn't test the exact GEOGRAPHY/GEOMETRY type 240
714+ // panic from the driver, it proves that the defer/recover mechanism works correctly
715+ // and any panic (including the type 240 panic) will be caught and converted to an error.
716+ //
717+ // The actual GEOGRAPHY/GEOMETRY panic occurs deep inside the go-mssqldb driver's
718+ // makeGoLangScanType function when it encounters type 240. Our safeColumnTypes
719+ // wrapper ensures this panic is caught regardless of where in the ColumnTypes()
720+ // call stack it originates.
711721func TestSafeColumnTypesHandlesPanic (t * testing.T ) {
712- // Create a mock Rows that will panic when ColumnTypes is called
713- // Since we cannot easily mock sql.Rows, we test the panic recovery mechanism
714- // by calling the function with a nil Rows pointer, which will panic
715-
716- // This test verifies that the defer/recover mechanism works
717- // In a real scenario with GEOGRAPHY/GEOMETRY types, the driver would panic
718- // inside ColumnTypes() and our function should catch it
719-
720- // We can't easily create a failing sql.Rows without a real database connection
721- // but we can at least verify the function exists and doesn't panic with nil
722+ // Verify that the defer/recover mechanism works by triggering any panic
722723 defer func () {
723724 if r := recover (); r != nil {
724725 t .Errorf ("safeColumnTypes should not panic, but got: %v" , r )
0 commit comments