diff --git a/contrib/drivers/sqlite/sqlite_core_test.go b/contrib/drivers/sqlite/sqlite_core_test.go index 45c9600a0..e8fafdf14 100644 --- a/contrib/drivers/sqlite/sqlite_core_test.go +++ b/contrib/drivers/sqlite/sqlite_core_test.go @@ -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() diff --git a/database/gdb/gdb_core_config.go b/database/gdb/gdb_core_config.go index bf6ca8a16..4e66b68f9 100644 --- a/database/gdb/gdb_core_config.go +++ b/database/gdb/gdb_core_config.go @@ -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]