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

os/gtime: issue parseConfigNodeLink source problem in mysl_open after removing node.Link = "" #4123

Open
sunerlin opened this issue Jan 18, 2025 · 0 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@sunerlin
Copy link

Go version

1.23.4

GoFrame version

2.8.3

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

config.yaml中

database:
  logger:
    level:   "all"
    stdout:  true
    Path: "resource/log/sql"

  default:
    link:   "mysql:root:123456@tcp(127.0.0.1:3306)/gfast?charset=utf8mb4&parseTime=true&loc=Local"
    debug:  true
    charset: "utf8mb4" #数据库编码
    dryRun: false #空跑
    maxIdle: 10 #连接池最大闲置的连接数
    maxOpen: 10 #连接池最大打开的连接数
    maxLifetime: "30s" #(单位秒)连接对象可重复使用的时间长度

What did you see happen?

2.7.2中parseConfigNodeLink解析后会node.Link = "",从而mysql_open.go

if config.Link != "" {
	source = config.Link
	// Custom changing the schema in runtime.
	if config.Name != "" {
		source, _ = gregex.ReplaceString(`/([\w\.\-]+)+`, "/"+config.Name, source)
	}
} else {
	// TODO: Do not set charset when charset is not specified (in v2.5.0)
	source = fmt.Sprintf(
		"%s:%s@%s(%s:%s)/%s?charset=%s",
		config.User, config.Pass, config.Protocol, config.Host, config.Port, config.Name, config.Charset,
	)
}

会从User开始取字符串,但2.8.3中会直接将整个link赋值给source,使得在ParseDSN中将类型'mysql'识别为用户名导致数据库连接失败

What did you expect to see?

是否是新版本中调整了link的写法还是该问题是一个bug

@sunerlin sunerlin added the bug It is confirmed a bug, but don't worry, we'll handle it. label Jan 18, 2025
@Issues-translate-bot Issues-translate-bot changed the title os/gtime: issue parseConfigNodeLink將node.Link = ""移除后mysl_open中的source问题 os/gtime: issue parseConfigNodeLink source problem in mysl_open after removing node.Link = "" Jan 18, 2025
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