Ignore schema when dbtype is not postgres (#1593)

Ignore schema when dbtype is not postgres

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1593
This commit is contained in:
Lunny Xiao 2020-03-10 13:15:18 +00:00
parent 6485adb722
commit 537d82a6f7
2 changed files with 9 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import (
"xorm.io/xorm/schemas" "xorm.io/xorm/schemas"
) )
// URI represents an uri to visit database
type URI struct { type URI struct {
DBType schemas.DBType DBType schemas.DBType
Proto string Proto string
@ -29,6 +30,13 @@ type URI struct {
Schema string 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 // Dialect represents a kind of database
type Dialect interface { type Dialect interface {
Init(*core.DB, *URI) error Init(*core.DB, *URI) error

View File

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