Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdb: custom driver is invalid #3787

Open
wanov opened this issue Sep 19, 2024 · 0 comments
Open

gdb: custom driver is invalid #3787

wanov opened this issue Sep 19, 2024 · 0 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@wanov
Copy link
Contributor

wanov commented Sep 19, 2024

Go version

go1.21

GoFrame version

2.7.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

package main
import (
	"database/sql"
	"fmt"
	"github.com/gogf/gf/contrib/drivers/mysql/v2"
	"github.com/gogf/gf/v2/database/gdb"
	"github.com/gogf/gf/v2/frame/g"
)

func main() {
	if err := gdb.Register("MyBizDriver", &MyBizDriver{}); err != nil {
		panic(err)
	}
	s, err := g.Model("sys_log").One()
	fmt.Println(s, err)
}

type MyBizDriver struct {
	*mysql.Driver
}

func (d *MyBizDriver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) {
	config.User = "aaaa"  // **bug: 这里就没执行**
	config.Pass = "bbbb"
	return d.Driver.Open(config)
}

func (d *MyBizDriver) decode(s string) string {
	// 执行字段解密处理逻辑
	// ...
	return s
}

config.yaml

database:
  default:
    link: "MyBizDriver:root:123456@tcp(127.0.0.1:3306)/test"
    timezone: "Asia/Shanghai"
    debug: true

What did you see happen?

The Open function is not executed

What did you expect to see?

The Open function executed

@wanov wanov added the bug It is confirmed a bug, but don't worry, we'll handle it. label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

1 participant