Skip to content

Commit 2c5cd05

Browse files
committed
remove lib/pq imports, add shim to register jackc/pgx stdlib driver as 'postgres'
1 parent e6db5aa commit 2c5cd05

File tree

7 files changed

+27
-7
lines changed

7 files changed

+27
-7
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ require (
9292
github.com/klauspost/compress v1.18.1
9393
github.com/klauspost/pgzip v1.2.6
9494
github.com/knights-analytics/hugot v0.4.3
95-
github.com/lib/pq v1.10.9
9695
github.com/linkedin/goavro/v2 v2.12.0
9796
github.com/matoous/go-nanoid/v2 v2.0.0
9897
github.com/microcosm-cc/bluemonday v1.0.27

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,8 +1484,8 @@ github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
14841484
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
14851485
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
14861486
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
1487-
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
1488-
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
1487+
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
1488+
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
14891489
github.com/linkedin/goavro/v2 v2.12.0 h1:rIQQSj8jdAUlKQh6DttK8wCRv4t4QO09g1C4aBWXslg=
14901490
github.com/linkedin/goavro/v2 v2.12.0/go.mod h1:KXx+erlq+RPlGSPmLF7xGo6SAbh8sCQ53x064+ioxhk=
14911491
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package postgrespgx
2+
3+
import (
4+
"database/sql"
5+
6+
"github.com/jackc/pgx/v4/stdlib"
7+
)
8+
9+
func init() {
10+
// Register pgx under the postgres driver name so existing configurations
11+
// using `postgres` continue to work with the pgx stdlib driver.
12+
for _, name := range sql.Drivers() {
13+
if name == "postgres" {
14+
return
15+
}
16+
}
17+
sql.Register("postgres", stdlib.GetDefaultDriver())
18+
}

internal/impl/cockroachdb/exploration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/stretchr/testify/assert"
1414
"github.com/stretchr/testify/require"
1515

16-
_ "github.com/lib/pq"
16+
_ "github.com/warpstreamlabs/bento/internal/driver/postgrespgx"
1717

1818
_ "github.com/warpstreamlabs/bento/public/components/io"
1919
_ "github.com/warpstreamlabs/bento/public/components/pure"

internal/impl/cockroachdb/input_changefeed.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import (
1717
"github.com/Jeffail/shutdown"
1818

1919
"github.com/warpstreamlabs/bento/public/service"
20-
21-
_ "github.com/lib/pq"
2220
)
2321

2422
var sampleString = `{
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package sql
2+
3+
import (
4+
_ "github.com/warpstreamlabs/bento/internal/driver/postgrespgx"
5+
)

public/components/sql/package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
_ "github.com/denisenkom/go-mssqldb"
1414
_ "github.com/go-sql-driver/mysql"
1515
_ "github.com/googleapis/go-sql-spanner"
16-
_ "github.com/lib/pq"
1716
_ "github.com/microsoft/gocosmos"
1817
_ "github.com/sijms/go-ora/v2"
1918
_ "github.com/trinodb/trino-go-client/trino"
19+
_ "github.com/warpstreamlabs/bento/internal/driver/postgrespgx"
2020
)

0 commit comments

Comments
 (0)