1
1
mirror of https://github.com/go-gitea/gitea synced 2025-11-01 11:58:25 +00:00

Refactor db package (#35380)

Remove unnecessary code
This commit is contained in:
wxiaoguang
2025-08-30 01:04:06 +08:00
committed by GitHub
parent aef4a3514c
commit 1f50048ac9
11 changed files with 37 additions and 52 deletions

View File

@@ -45,7 +45,7 @@ func CheckConsistencyFor(t TestingT, beansToCheck ...any) {
}
func checkForConsistency(t TestingT, bean any) {
tb, err := db.TableInfo(bean)
tb, err := GetXORMEngine().TableInfo(bean)
assert.NoError(t, err)
f := consistencyCheckMap[tb.Name]
require.NotNil(t, f, "unknown bean type: %#v", bean)

View File

@@ -218,7 +218,7 @@ func NewFixturesLoader(x *xorm.Engine, opts FixturesOptions) (FixturesLoader, er
xormBeans, _ := db.NamesToBean()
f.xormTableNames = map[string]bool{}
for _, bean := range xormBeans {
f.xormTableNames[db.TableName(bean)] = true
f.xormTableNames[x.TableName(bean)] = true
}
return f, nil

View File

@@ -159,7 +159,7 @@ func DumpQueryResult(t require.TestingT, sqlOrBean any, sqlArgs ...any) {
goDB := x.DB().DB
sql, ok := sqlOrBean.(string)
if !ok {
sql = "SELECT * FROM " + db.TableName(sqlOrBean)
sql = "SELECT * FROM " + x.TableName(sqlOrBean)
} else if !strings.Contains(sql, " ") {
sql = "SELECT * FROM " + sql
}