"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "models/models.go" between
gitea-1.13.1.tar.gz and gitea-1.13.2.tar.gz

About: Gitea allows to set up a self-hosted code hosting Git service (a fork of Gogs).

models.go  (gitea-1.13.1):models.go  (gitea-1.13.2)
skipping to change at line 18 skipping to change at line 18
import ( import (
"context" "context"
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"reflect" "reflect"
"strings" "strings"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
// Needed for the MySQL driver "xorm.io/builder"
_ "github.com/go-sql-driver/mysql"
"xorm.io/xorm" "xorm.io/xorm"
"xorm.io/xorm/names" "xorm.io/xorm/names"
"xorm.io/xorm/schemas" "xorm.io/xorm/schemas"
// Needed for the MySQL driver
_ "github.com/go-sql-driver/mysql"
// Needed for the Postgresql driver // Needed for the Postgresql driver
_ "github.com/lib/pq" _ "github.com/lib/pq"
// Needed for the MSSQL driver // Needed for the MSSQL driver
_ "github.com/denisenkom/go-mssqldb" _ "github.com/denisenkom/go-mssqldb"
) )
// Engine represents a xorm engine or session. // Engine represents a xorm engine or session.
type Engine interface { type Engine interface {
Table(tableNameOrBean interface{}) *xorm.Session Table(tableNameOrBean interface{}) *xorm.Session
skipping to change at line 148 skipping to change at line 150
names.LintGonicMapper[name] = true names.LintGonicMapper[name] = true
} }
} }
func getEngine() (*xorm.Engine, error) { func getEngine() (*xorm.Engine, error) {
connStr, err := setting.DBConnStr() connStr, err := setting.DBConnStr()
if err != nil { if err != nil {
return nil, err return nil, err
} }
engine, err := xorm.NewEngine(setting.Database.Type, connStr) var engine *xorm.Engine
if setting.Database.UsePostgreSQL && len(setting.Database.Schema) > 0 {
// OK whilst we sort out our schema issues - create a schema awar
e postgres
registerPostgresSchemaDriver()
engine, err = xorm.NewEngine("postgresschema", connStr)
} else {
engine, err = xorm.NewEngine(setting.Database.Type, connStr)
}
if err != nil { if err != nil {
return nil, err return nil, err
} }
if setting.Database.Type == "mysql" { if setting.Database.Type == "mysql" {
engine.Dialect().SetParams(map[string]string{"rowFormat": "DYNAMI C"}) engine.Dialect().SetParams(map[string]string{"rowFormat": "DYNAMI C"})
} else if setting.Database.Type == "mssql" { } else if setting.Database.Type == "mssql" {
engine.Dialect().SetParams(map[string]string{"DEFAULT_VARCHAR": " nvarchar"}) engine.Dialect().SetParams(map[string]string{"DEFAULT_VARCHAR": " nvarchar"})
} }
engine.SetSchema(setting.Database.Schema) engine.SetSchema(setting.Database.Schema)
if setting.Database.UsePostgreSQL && len(setting.Database.Schema) > 0 {
// Add the schema to the search path
if _, err := engine.Exec(`SELECT set_config(
'search_path',
? || ',' || current_setting('search_path'),
false)`,
setting.Database.Schema); err != nil {
return nil, err
}
}
return engine, nil return engine, nil
} }
// NewTestEngine sets a new test xorm.Engine // NewTestEngine sets a new test xorm.Engine
func NewTestEngine() (err error) { func NewTestEngine() (err error) {
x, err = getEngine() x, err = getEngine()
if err != nil { if err != nil {
return fmt.Errorf("Connect to database: %v", err) return fmt.Errorf("Connect to database: %v", err)
} }
skipping to change at line 316 skipping to change at line 317
func DumpDatabase(filePath string, dbType string) error { func DumpDatabase(filePath string, dbType string) error {
var tbs []*schemas.Table var tbs []*schemas.Table
for _, t := range tables { for _, t := range tables {
t, err := x.TableInfo(t) t, err := x.TableInfo(t)
if err != nil { if err != nil {
return err return err
} }
tbs = append(tbs, t) tbs = append(tbs, t)
} }
// temporary fix for v1.13.x (https://github.com/go-gitea/gitea/issues/14
069)
if _, err := x.Where(builder.IsNull{"keep_activity_private"}).
Cols("keep_activity_private").
Update(User{KeepActivityPrivate: false}); err != nil {
return err
}
type Version struct { type Version struct {
ID int64 `xorm:"pk autoincr"` ID int64 `xorm:"pk autoincr"`
Version int64 Version int64
} }
t, err := x.TableInfo(Version{}) t, err := x.TableInfo(Version{})
if err != nil { if err != nil {
return err return err
} }
tbs = append(tbs, t) tbs = append(tbs, t)
 End of changes. 5 change blocks. 
13 lines changed or deleted 23 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)