Ignore schema when dbtype is not postgres #1593

Merged
lunny merged 1 commits from lunny/ignore_schema into master 2020-03-10 13:15:22 +00:00
2 changed files with 9 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import (
"xorm.io/xorm/schemas"
)
// URI represents an uri to visit database
type URI struct {
DBType schemas.DBType
Proto string
@ -29,6 +30,13 @@ type URI struct {
Schema string
}
// SetSchema set schema
func (uri URI) SetSchema(schema string) {
if uri.DBType == schemas.POSTGRES {
uri.Schema = schema
}
}
// Dialect represents a kind of database
type Dialect interface {
Init(*core.DB, *URI) error

View File

@ -1245,7 +1245,7 @@ func (engine *Engine) SetTZDatabase(tz *time.Location) {
// SetSchema sets the schema of database
func (engine *Engine) SetSchema(schema string) {
engine.dialect.URI().Schema = schema
engine.dialect.URI().SetSchema(schema)
}
// Unscoped always disable struct tag "deleted"