@@ -402,7 +402,7 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
402402 cols += "DROP COLUMN `" + col + "` CASCADE"
403403 }
404404 if _ , err := sess .Exec (fmt .Sprintf ("ALTER TABLE `%s` %s" , tableName , cols )); err != nil {
405- return fmt .Errorf ("Drop table `%s` columns %v: %v " , tableName , columnNames , err )
405+ return fmt .Errorf ("drop table `%s` columns %v: %w " , tableName , columnNames , err )
406406 }
407407 case setting .Database .Type .IsMySQL ():
408408 // Drop indexes on columns first
@@ -430,7 +430,7 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
430430 cols += "DROP COLUMN `" + col + "`"
431431 }
432432 if _ , err := sess .Exec (fmt .Sprintf ("ALTER TABLE `%s` %s" , tableName , cols )); err != nil {
433- return fmt .Errorf ("Drop table `%s` columns %v: %v " , tableName , columnNames , err )
433+ return fmt .Errorf ("drop table `%s` columns %v: %w " , tableName , columnNames , err )
434434 }
435435 case setting .Database .Type .IsMSSQL ():
436436 cols := ""
@@ -444,27 +444,27 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
444444 tableName , strings .ReplaceAll (cols , "`" , "'" ))
445445 constraints := make ([]string , 0 )
446446 if err := sess .SQL (sql ).Find (& constraints ); err != nil {
447- return fmt .Errorf ("Find constraints: %v " , err )
447+ return fmt .Errorf ("find constraints: %w " , err )
448448 }
449449 for _ , constraint := range constraints {
450450 if _ , err := sess .Exec (fmt .Sprintf ("ALTER TABLE `%s` DROP CONSTRAINT `%s`" , tableName , constraint )); err != nil {
451- return fmt .Errorf ("Drop table `%s` default constraint `%s`: %v " , tableName , constraint , err )
451+ return fmt .Errorf ("drop table `%s` default constraint `%s`: %w " , tableName , constraint , err )
452452 }
453453 }
454454 sql = fmt .Sprintf ("SELECT DISTINCT Name FROM sys.indexes INNER JOIN sys.index_columns ON indexes.index_id = index_columns.index_id AND indexes.object_id = index_columns.object_id WHERE indexes.object_id = OBJECT_ID('%[1]s') AND index_columns.column_id IN (SELECT column_id FROM sys.columns WHERE LOWER(name) IN (%[2]s) AND object_id = OBJECT_ID('%[1]s'))" ,
455455 tableName , strings .ReplaceAll (cols , "`" , "'" ))
456456 constraints = make ([]string , 0 )
457457 if err := sess .SQL (sql ).Find (& constraints ); err != nil {
458- return fmt .Errorf ("Find constraints: %v " , err )
458+ return fmt .Errorf ("find constraints: %w " , err )
459459 }
460460 for _ , constraint := range constraints {
461461 if _ , err := sess .Exec (fmt .Sprintf ("DROP INDEX `%[2]s` ON `%[1]s`" , tableName , constraint )); err != nil {
462- return fmt .Errorf ("Drop index `%[2]s` on `%[1]s`: %v " , tableName , constraint , err )
462+ return fmt .Errorf ("drop index `%[2]s` on `%[1]s`: %[3]w " , tableName , constraint , err )
463463 }
464464 }
465465
466466 if _ , err := sess .Exec (fmt .Sprintf ("ALTER TABLE `%s` DROP COLUMN %s" , tableName , cols )); err != nil {
467- return fmt .Errorf ("Drop table `%s` columns %v: %v " , tableName , columnNames , err )
467+ return fmt .Errorf ("drop table `%s` columns %v: %w " , tableName , columnNames , err )
468468 }
469469 default :
470470 log .Fatal ("Unrecognized DB" )
0 commit comments