Skip to content

Commit 05b60c5

Browse files
author
Ezequiel Raynaudo
authored
Merge pull request #14 from Zondax/fix-gorm-update
Fix for Gorm update
2 parents 0ca238e + 38ec0ad commit 05b60c5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

connections/database/postgres.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ type DBConnectionConfig struct {
1414
Gorm *gorm.Config
1515
}
1616

17-
func NewPostgresConnection(params *DBConnectionParams, config *DBConnectionConfig) (*GormConnection, error) {
17+
func NewPostgresConnection(params *DBConnectionParams, config DBConnectionConfig) (*GormConnection, error) {
1818
dsn, err := params.GetDSN()
1919
if err != nil {
2020
return nil, fmt.Errorf("failed to retrieve dsn")
2121
}
2222

23-
conn, err := gorm.Open(postgres.Open(dsn), config.Gorm)
23+
var dbConfig gorm.Config
24+
if config.Gorm != nil {
25+
dbConfig = *config.Gorm
26+
}
27+
conn, err := gorm.Open(postgres.Open(dsn), &dbConfig)
2428

2529
if err != nil {
2630
return nil, fmt.Errorf("failed to dial connect to db '%s@%s:%s': %v", params.Name, params.Host, params.Port, err)
@@ -36,7 +40,7 @@ func (c *GormConnection) GetDB() *gorm.DB {
3640
}
3741

3842
func ConnectDB(params DBConnectionParams, config DBConnectionConfig) (*gorm.DB, error) {
39-
conn, err := NewPostgresConnection(&params, &config)
43+
conn, err := NewPostgresConnection(&params, config)
4044
if err != nil {
4145
return nil, err
4246
}

0 commit comments

Comments
 (0)