This commit is contained in:
glennliao
2023-02-13 19:18:30 +08:00
committed by GitHub
parent 005668aca8
commit 0361f9f7de
2 changed files with 22 additions and 1 deletions

View File

@ -38,6 +38,27 @@ func Test_New(t *testing.T) {
})
}
func Test_New_Path_With_Colon(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
dbFilePathWithColon := gfile.Join(dbDir, "test:1")
if err := gfile.Mkdir(dbFilePathWithColon); err != nil {
gtest.Error(err)
}
node := gdb.ConfigNode{
Type: "sqlite",
Link: fmt.Sprintf(`sqlite::@file(%s)`, gfile.Join(dbFilePathWithColon, "test.db")),
Charset: "utf8",
}
newDb, err := gdb.New(node)
t.AssertNil(err)
value, err := newDb.GetValue(ctx, `select 1`)
t.AssertNil(err)
t.Assert(value, `1`)
t.AssertNil(newDb.Close(ctx))
})
}
func Test_DB_Ping(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
err1 := db.PingMaster()

View File

@ -276,7 +276,7 @@ func parseConfigNodeLink(node *ConfigNode) *ConfigNode {
node.Pass = match[3]
node.Protocol = match[4]
array := gstr.Split(match[5], ":")
if len(array) == 2 {
if len(array) == 2 && node.Protocol != "file" {
node.Host = array[0]
node.Port = array[1]
node.Name = match[6]