* refact: Changes required for gorm v2 * refact: Add db.DB wrapper and refact all test fixtures to use it Stop leaking the gorm abstraction within our unit tests. * refact: Migrate direct calls to pq to pgx driver The refactor will remove the remaining direct dependencies on the pq driver which has been deprecated in favor of the pgx driver. It includes the addition of common.SqlOpen which is a wrapper around sql.Open, which is needed to deal with the driver name changing from "postgres" to "pgx" but in our code base the dialect and driver are synonyms.
16 lines
258 B
Go
16 lines
258 B
Go
package common
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
_ "github.com/jackc/pgx/v4"
|
|
)
|
|
|
|
func SqlOpen(driverName, dataSourceName string) (*sql.DB, error) {
|
|
switch driverName {
|
|
case "postgres", "pgx":
|
|
driverName = "pgx"
|
|
}
|
|
return sql.Open(driverName, dataSourceName)
|
|
}
|