Skip to content

Commit 5fd75be

Browse files
author
Radosław Skałbania
committed
feat: support postgresql url prefix
Signed-off-by: Radosław Skałbania <[email protected]>
1 parent 97c7ed6 commit 5fd75be

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

internal/storage/sql/db.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func init() {
5252
// drop references to lib/pq and relay on pgx
5353
dburl.Unregister("postgres")
5454
dburl.RegisterAlias("pgx", "postgres")
55+
dburl.RegisterAlias("pgx", "postgresql")
5556
}
5657

5758
// Open opens a connection to the db

internal/storage/sql/db_internal_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@ func TestParse(t *testing.T) {
3434
driver: SQLite,
3535
dsn: "flipt.db?_fk=true&cache=shared&mode=rwc",
3636
},
37+
{
38+
name: "postgresql url",
39+
cfg: config.DatabaseConfig{
40+
URL: "postgresql://postgres@localhost:5432/flipt?sslmode=disable",
41+
},
42+
driver: Postgres,
43+
dsn: "postgres://postgres@localhost:5432/flipt?binary_parameters=yes&sslmode=disable",
44+
},
45+
{
46+
name: "postgresql url prepared statements enabled",
47+
cfg: config.DatabaseConfig{
48+
URL: "postgresql://postgres@localhost:5432/flipt?sslmode=disable",
49+
PreparedStatementsEnabled: true,
50+
},
51+
driver: Postgres,
52+
dsn: "postgres://postgres@localhost:5432/flipt?sslmode=disable",
53+
},
54+
{
55+
name: "postgresql no disable sslmode",
56+
cfg: config.DatabaseConfig{
57+
URL: "postgresql://postgres@localhost:5432/flipt",
58+
},
59+
driver: Postgres,
60+
dsn: "postgres://postgres@localhost:5432/flipt?binary_parameters=yes",
61+
},
3762
{
3863
name: "postgres url prepared statements enabled",
3964
cfg: config.DatabaseConfig{

0 commit comments

Comments
 (0)