Skip to content

Commit

Permalink
Test postgres compatibility with github.com/jackc/pgx/v5 (#167)
Browse files Browse the repository at this point in the history
* Test postgres compatibility with jackc/pgx/v5

* Fix postgres driver in the workflow

* Bump jackc/pgx
  • Loading branch information
nhatthm authored Feb 28, 2023
1 parent e8d12b3 commit 22e22ba
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ jobs:
go-version: [ 1.19.x, 1.20.x ]
arch: [ "386", amd64 ]
postgres-version: [ "12", "13", "14", "15" ]
postgres-driver: [ "postgres", "pgx" ]
postgres-driver: [ "postgres", "pgx/v4", "pgx/v5" ]
runs-on: ubuntu-latest
needs: test-unit
steps:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-compatibility-pgx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
go-version: [ 1.19.x, 1.20.x ]
arch: [ "386", amd64 ]
postgres-version: [ "12", "13", "14", "15" ]
pgx-version: [ "v4", "v5"]
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand Down Expand Up @@ -49,6 +50,6 @@ jobs:
env:
GOARCH: ${{ matrix.arch }}
POSTGRES_VERSION: ${{ matrix.postgres-version }}-alpine
POSTGRES_DRIVER: pgx
POSTGRES_DRIVER: pgx/${{ matrix.pgx-version }}
run: |
make test-compatibility-postgres
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GO ?= go
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION)
GHERKIN_LINT ?= gherkin-lint

TEST_FLAGS = -race
TEST_FLAGS ?= -race
COMPATIBILITY_TEST ?= postgres

GITHUB_OUTPUT ?= /dev/null
Expand Down Expand Up @@ -74,7 +74,7 @@ test-unit:
$(compatibilityTests):
$(eval COMPATIBILITY_TEST := "$(subst test-compatibility-,,$@)")
@echo ">> compatibility test: $(COMPATIBILITY_TEST)"
@cd "tests/$(COMPATIBILITY_TEST)"; $(GO) test -gcflags=-l -v ./...
@cd "tests/$(COMPATIBILITY_TEST)"; $(GO) test -gcflags=-l -v $(TEST_FLAGS) ./...
@echo

.PHONY: test-compatibility
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,22 @@ The traces are almost identical with some minor changes:
</tr>
<tr>
<td>
<code style="white-space: nowrap">jackc/pgx/stdlib</code>
<code style="white-space: nowrap">jackc/pgx/v4/stdlib</code>
</td>
<td style="white-space: nowrap">
Postgres 12, 13, 14, 15
</td>
<td colspan="6" align="center">
<a href="https://github.com/nhatthm/otelsql/actions/workflows/test-compatibility-pgx.yaml">
<img
src="https://github.com/nhatthm/otelsql/actions/workflows/test-compatibility-pgx.yaml/badge.svg?branch=master" alt="Build Status"
style="max-width: 100%;">
</a>
</td>
</tr>
<tr>
<td>
<code style="white-space: nowrap">jackc/pgx/v5/stdlib</code>
</td>
<td style="white-space: nowrap">
Postgres 12, 13, 14, 15
Expand Down
1 change: 1 addition & 0 deletions tests/postgres/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.18
require (
github.com/Masterminds/squirrel v1.5.3
github.com/jackc/pgx/v4 v4.18.1
github.com/jackc/pgx/v5 v5.3.1
github.com/lib/pq v1.10.7
go.nhat.io/clock v0.7.0
go.nhat.io/otelsql/tests/suite v0.0.0-20220127125055-5da30ca2778a
Expand Down
2 changes: 2 additions & 0 deletions tests/postgres/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,8 @@ github.com/jackc/pgx/v4 v4.10.1/go.mod h1:QlrWebbs3kqEZPHCTGyxecvzG6tvIsYu+A5b1r
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
github.com/jackc/pgx/v4 v4.18.1 h1:YP7G1KABtKpB5IHrO9vYwSrCOhs7p3uqhvhhQBptya0=
github.com/jackc/pgx/v4 v4.18.1/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzkb+qQE=
github.com/jackc/pgx/v5 v5.3.1 h1:Fcr8QJ1ZeLi5zsPZqQeUZhNhxfkkKBOgJuYkJHoBOtU=
github.com/jackc/pgx/v5 v5.3.1/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
Expand Down
3 changes: 2 additions & 1 deletion tests/postgres/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/Masterminds/squirrel"
_ "github.com/jackc/pgx/v4/stdlib" // Database driver
_ "github.com/jackc/pgx/v5/stdlib" // Database driver
_ "github.com/lib/pq" // Database driver
"go.nhat.io/testcontainers-extra"
pg "go.nhat.io/testcontainers-registry/postgres"
Expand All @@ -15,7 +16,7 @@ import (

const (
defaultVersion = "12-alpine"
defaultDriver = "pgx"
defaultDriver = "pgx/v4"

databaseName = "otelsql"
databaseUsername = "otelsql"
Expand Down

0 comments on commit 22e22ba

Please sign in to comment.