-
Notifications
You must be signed in to change notification settings - Fork 28
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
DSNをDSNconfigを使用する形に変更 #2465
DSNをDSNconfigを使用する形に変更 #2465
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
レビュー遅くてごめんなさい!
貢献ありがとうございます!かなり良く書けていると思います!
一箇所だけ気になった点があるので、確認お願いします~!
repository/gorm/repository_test.go
Outdated
config.DBName = fmt.Sprintf("%s%s", dbPrefix, key) | ||
engine, err := gorm.Open(mysql.New(mysql.Config{ | ||
DSN: fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", user, pass, host, port, fmt.Sprintf("%s%s", dbPrefix, key)), | ||
DSNConfig: config, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
結構細かいですが、
この実装は config.DBName = fmt.Sprintf("%s%s", dbPrefix, key)
と config
構造体の元の値を直接変更してるけど、以下の様に元の値を直接変更するのではなくコピーしてから変更した方が、コードの意図が明確になって、さらに他の部分への影響を防ぐことでメンテナンス上でバグが起きにくくなりそうです!
config.DBName = fmt.Sprintf("%s%s", dbPrefix, key) | |
engine, err := gorm.Open(mysql.New(mysql.Config{ | |
DSN: fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", user, pass, host, port, fmt.Sprintf("%s%s", dbPrefix, key)), | |
DSNConfig: config, | |
dbConfig := *config | |
dbConfig.DBName = fmt.Sprintf("%s%s", dbPrefix, key) | |
engine, err := gorm.Open(mysql.New(mysql.Config{ | |
DSNConfig: &dbConfig, |
router/oauth2/oauth2_test.go
Outdated
config.DBName = fmt.Sprintf("%s%s", dbPrefix, key) | ||
|
||
// テスト用データベース接続 | ||
engine, err := gorm.Open(mysql.New(mysql.Config{ | ||
DSN: fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", user, pass, host, port, fmt.Sprintf("%s%s", dbPrefix, key)), | ||
DSNConfig: config, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ココも同様
router/v3/router_test.go
Outdated
config.DBName = fmt.Sprintf("%s%s", dbPrefix, key) | ||
l := zap.NewNop() | ||
|
||
// テスト用データベース接続 | ||
engine, err := gorm.Open(mysql.New(mysql.Config{ | ||
DSN: fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", user, pass, host, port, fmt.Sprintf("%s%s", dbPrefix, key)), | ||
DSNConfig: config, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ココも同様
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
レビュー遅くてごめんなさい!LGTM;良さそうです!
お疲れさまでした~!
resolve: #1873