Fix setschema
This commit is contained in:
parent
b7b2b21a40
commit
5f616ccc5e
|
@ -31,7 +31,7 @@ type URI struct {
|
|||
}
|
||||
|
||||
// SetSchema set schema
|
||||
func (uri URI) SetSchema(schema string) {
|
||||
func (uri *URI) SetSchema(schema string) {
|
||||
if uri.DBType == schemas.POSTGRES {
|
||||
uri.Schema = schema
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
func TestPingContext(t *testing.T) {
|
||||
|
@ -97,3 +98,15 @@ func TestDump(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.NoError(t, sess.Commit())
|
||||
}
|
||||
|
||||
func TestSetSchema(t *testing.T) {
|
||||
assert.NoError(t, prepareEngine())
|
||||
|
||||
if testEngine.Dialect().URI().DBType == schemas.POSTGRES {
|
||||
oldSchema := testEngine.Dialect().URI().Schema
|
||||
testEngine.SetSchema("my_schema")
|
||||
assert.EqualValues(t, "my_schema", testEngine.Dialect().URI().Schema)
|
||||
testEngine.SetSchema(oldSchema)
|
||||
assert.EqualValues(t, oldSchema, testEngine.Dialect().URI().Schema)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue