address review lint issues (#4354)

This commit is contained in:
6543
2024-11-11 15:25:31 +01:00
committed by GitHub
parent 759e5497c9
commit 07baae28af
3 changed files with 12 additions and 12 deletions

View File

@@ -23,14 +23,14 @@ import (
"xorm.io/xorm/schemas"
)
func renameTable(sess *xorm.Session, old, new string) error {
func renameTable(sess *xorm.Session, oldTable, newTable string) error {
dialect := sess.Engine().Dialect().URI().DBType
switch dialect {
case schemas.MYSQL:
_, err := sess.Exec(fmt.Sprintf("RENAME TABLE `%s` TO `%s`;", old, new))
_, err := sess.Exec(fmt.Sprintf("RENAME TABLE `%s` TO `%s`;", oldTable, newTable))
return err
case schemas.POSTGRES, schemas.SQLITE:
_, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` RENAME TO `%s`;", old, new))
_, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` RENAME TO `%s`;", oldTable, newTable))
return err
default:
return fmt.Errorf("dialect '%s' not supported", dialect)

View File

@@ -57,14 +57,14 @@ func createSQLiteDB(t *testing.T) string {
return tmpF.Name()
}
func testDB(t *testing.T, new bool) (engine *xorm.Engine, closeDB func()) {
func testDB(t *testing.T, initNewDB bool) (engine *xorm.Engine, closeDB func()) {
driver := testDriver()
var err error
closeDB = func() {}
switch driver {
case "sqlite3":
config := ":memory:"
if !new {
if !initNewDB {
config = createSQLiteDB(t)
closeDB = func() {
_ = os.Remove(config)
@@ -77,7 +77,7 @@ func testDB(t *testing.T, new bool) (engine *xorm.Engine, closeDB func()) {
return
case "mysql", "postgres":
config := os.Getenv("WOODPECKER_DATABASE_DATASOURCE")
if !new {
if !initNewDB {
t.Logf("do not have dump to test against")
t.SkipNow()
}