mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-16 11:00:02 +02:00
Upgrade xorm to v1.0.0 (#10646)
* Upgrade xorm to v1.0.0 * small nit * Fix tests * Update xorm * Update xorm * fix go.sum * fix test * Fix bug when dump * Fix bug * update xorm to latest * Fix migration test * update xorm to latest * Fix import order * Use xorm tag
This commit is contained in:
parent
dcaa5643d7
commit
c61b902538
154 changed files with 7195 additions and 5962 deletions
|
@ -15,8 +15,9 @@ import (
|
|||
|
||||
// Needed for the MySQL driver
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"xorm.io/core"
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/names"
|
||||
"xorm.io/xorm/schemas"
|
||||
|
||||
// Needed for the Postgresql driver
|
||||
_ "github.com/lib/pq"
|
||||
|
@ -127,7 +128,7 @@ func init() {
|
|||
|
||||
gonicNames := []string{"SSL", "UID"}
|
||||
for _, name := range gonicNames {
|
||||
core.LintGonicMapper[name] = true
|
||||
names.LintGonicMapper[name] = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,8 +153,7 @@ func NewTestEngine(x *xorm.Engine) (err error) {
|
|||
return fmt.Errorf("Connect to database: %v", err)
|
||||
}
|
||||
|
||||
x.ShowExecTime(true)
|
||||
x.SetMapper(core.GonicMapper{})
|
||||
x.SetMapper(names.GonicMapper{})
|
||||
x.SetLogger(NewXORMLogger(!setting.ProdMode))
|
||||
x.ShowSQL(!setting.ProdMode)
|
||||
return x.StoreEngine("InnoDB").Sync2(tables...)
|
||||
|
@ -166,8 +166,7 @@ func SetEngine() (err error) {
|
|||
return fmt.Errorf("Failed to connect to database: %v", err)
|
||||
}
|
||||
|
||||
x.ShowExecTime(true)
|
||||
x.SetMapper(core.GonicMapper{})
|
||||
x.SetMapper(names.GonicMapper{})
|
||||
// WARNING: for serv command, MUST remove the output to os.stdout,
|
||||
// so use log file to instead print to stdout.
|
||||
x.SetLogger(NewXORMLogger(setting.Database.LogSQL))
|
||||
|
@ -249,21 +248,26 @@ func Ping() error {
|
|||
|
||||
// DumpDatabase dumps all data from database according the special database SQL syntax to file system.
|
||||
func DumpDatabase(filePath string, dbType string) error {
|
||||
var tbs []*core.Table
|
||||
var tbs []*schemas.Table
|
||||
for _, t := range tables {
|
||||
t := x.TableInfo(t)
|
||||
t.Table.Name = t.Name
|
||||
tbs = append(tbs, t.Table)
|
||||
t, err := x.TableInfo(t)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tbs = append(tbs, t)
|
||||
}
|
||||
if len(dbType) > 0 {
|
||||
return x.DumpTablesToFile(tbs, filePath, core.DbType(dbType))
|
||||
return x.DumpTablesToFile(tbs, filePath, schemas.DBType(dbType))
|
||||
}
|
||||
return x.DumpTablesToFile(tbs, filePath)
|
||||
}
|
||||
|
||||
// MaxBatchInsertSize returns the table's max batch insert size
|
||||
func MaxBatchInsertSize(bean interface{}) int {
|
||||
t := x.TableInfo(bean)
|
||||
t, err := x.TableInfo(bean)
|
||||
if err != nil {
|
||||
return 50
|
||||
}
|
||||
return 999 / len(t.ColumnsSeq())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue