Skip to content

Commit

Permalink
feat: support postgresql url prefix (#3354)
Browse files Browse the repository at this point in the history
Signed-off-by: Radosław Skałbania <[email protected]>
Co-authored-by: Radosław Skałbania <[email protected]>
  • Loading branch information
radekska and Radosław Skałbania authored Aug 5, 2024
1 parent 97c7ed6 commit 83964f1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/storage/sql/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func init() {
// drop references to lib/pq and relay on pgx
dburl.Unregister("postgres")
dburl.RegisterAlias("pgx", "postgres")
dburl.RegisterAlias("pgx", "postgresql")
}

// Open opens a connection to the db
Expand Down
25 changes: 25 additions & 0 deletions internal/storage/sql/db_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,31 @@ func TestParse(t *testing.T) {
driver: SQLite,
dsn: "flipt.db?_fk=true&cache=shared&mode=rwc",
},
{
name: "postgresql url",
cfg: config.DatabaseConfig{
URL: "postgresql://postgres@localhost:5432/flipt?sslmode=disable",
},
driver: Postgres,
dsn: "postgres://postgres@localhost:5432/flipt?binary_parameters=yes&sslmode=disable",
},
{
name: "postgresql url prepared statements enabled",
cfg: config.DatabaseConfig{
URL: "postgresql://postgres@localhost:5432/flipt?sslmode=disable",
PreparedStatementsEnabled: true,
},
driver: Postgres,
dsn: "postgres://postgres@localhost:5432/flipt?sslmode=disable",
},
{
name: "postgresql no disable sslmode",
cfg: config.DatabaseConfig{
URL: "postgresql://postgres@localhost:5432/flipt",
},
driver: Postgres,
dsn: "postgres://postgres@localhost:5432/flipt?binary_parameters=yes",
},
{
name: "postgres url prepared statements enabled",
cfg: config.DatabaseConfig{
Expand Down

0 comments on commit 83964f1

Please sign in to comment.