Skip to content

Commit

Permalink
use jackc/pgx as the primary driver for test (#161)
Browse files Browse the repository at this point in the history
This patch re-enables the dynamic schema change test for
jackc/pgx, teaches pggen to automatically retry queries
when there is an invalid plan error due to a dynamic schema
change, and makes jackc/pgx the default driver to test against
(though we still test against lib/pq in CI). We will probably
drop official support for lib/pq at some point soon, though I
plan to keep testing against it if the maintenance burden is
not too high.
  • Loading branch information
ethanpailes authored Mar 19, 2021
1 parent e323f65 commit 965dc46
Show file tree
Hide file tree
Showing 33 changed files with 441 additions and 88 deletions.
2 changes: 0 additions & 2 deletions cmd/pggen/test/prepared_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"regexp"
"testing"

_ "github.com/lib/pq"

"github.com/opendoor-labs/pggen/cmd/pggen/test/models"
)

Expand Down
7 changes: 0 additions & 7 deletions cmd/pggen/test/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package test

import (
"database/sql"
"os"
"reflect"
"sort"
"testing"
Expand Down Expand Up @@ -1120,12 +1119,6 @@ func TestNotFoundList(t *testing.T) {
}

func TestDroppingColumnOnTheFly(t *testing.T) {
if os.Getenv("DB_DRIVER") == "pgx" {
// disable this test for jackc/pgx
// TODO: re-enable once https://github.com/jackc/pgx/issues/841 is resolved
return
}

// make sure we always start in a consistant state
_, err := pgClient.Handle().ExecContext(ctx, `
DROP TABLE drop_cols;
Expand Down
2 changes: 1 addition & 1 deletion cmd/pggen/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func init() {

dbDriver, inEnv := os.LookupEnv("DB_DRIVER")
if !inEnv || dbDriver == "" {
dbDriver = "postgres" // default to using lib/pq
dbDriver = "pgx" // default to using jackc/pgx/v4/stdlib
}

db, err := sql.Open(dbDriver, dbURL)
Expand Down
6 changes: 3 additions & 3 deletions examples/extending_models/models/models.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion examples/extending_models/models/pggen_prelude.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/id_in_set/models/models.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion examples/id_in_set/models/pggen_prelude.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions examples/include_specs/models/models.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion examples/include_specs/models/pggen_prelude.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 965dc46

Please sign in to comment.