fix(database/gdb): unix socket connection support for mysql (#3872)

This commit is contained in:
John Guo
2024-10-21 09:22:53 +08:00
committed by GitHub
parent 7dd38a1700
commit e179e1d4fe
3 changed files with 67 additions and 14 deletions

View File

@ -232,7 +232,7 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) {
t.Assert(newNode.Charset, defaultCharset)
t.Assert(newNode.Protocol, `tcp`)
})
// #3755
// https://github.com/gogf/gf/issues/3755
gtest.C(t, func(t *gtest.T) {
node := &ConfigNode{
Link: "mysql:user:pwd@tcp(rdsid.mysql.rds.aliyuncs.com)/dbname?charset=utf8&loc=Local",
@ -248,6 +248,22 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) {
t.Assert(newNode.Charset, `utf8`)
t.Assert(newNode.Protocol, `tcp`)
})
// https://github.com/gogf/gf/issues/3862
gtest.C(t, func(t *gtest.T) {
node := &ConfigNode{
Link: "mysql:username:password@unix(/tmp/mysql.sock)/dbname",
}
newNode := parseConfigNodeLink(node)
t.Assert(newNode.Type, `mysql`)
t.Assert(newNode.User, `username`)
t.Assert(newNode.Pass, `password`)
t.Assert(newNode.Host, `/tmp/mysql.sock`)
t.Assert(newNode.Port, ``)
t.Assert(newNode.Name, `dbname`)
t.Assert(newNode.Extra, ``)
t.Assert(newNode.Charset, `utf8`)
t.Assert(newNode.Protocol, `unix`)
})
}
func Test_Func_doQuoteWord(t *testing.T) {