Skip to content

Commit

Permalink
fully switch over to jackc pgx (#163)
Browse files Browse the repository at this point in the history
This patch switches the generated code over to
use ethanpailes/pgtypes rather than lib/pq for
array scanning and fixes a few dangling odds and
ends where there were still references to lib/pq.

Closes #155
  • Loading branch information
ethanpailes authored Mar 22, 2021
1 parent 5d010c7 commit 97e8fea
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 86 deletions.
11 changes: 4 additions & 7 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,14 @@ so that we can share the source between the host and the container during local

## Testing Non-Default Drivers

`pggen` supports using both `github.com/lib/pq` and `github.com/jackc/pgx/stdlib` as
database drivers. For the moment `lib/pq` is recommended because `jackc/pgx` contains
a [nasty bug](https://github.com/jackc/pgx/issues/841) that prevents our test suite
from passing fully. Going forward we do want to switch to recommending `jackc/pgx`,
as it is more actively maintained than `lib/pq`.
`pggen` supports using both `github.com/lib/pq` and `github.com/jackc/pgx/v4/stdlib` as
database drivers. `jackc/pgx` is recommended because `lib/pq` is unmaintained.

The example tests all use the recommended driver (`lib/pq`) for testing to keep the example code
The example tests all use the recommended driver (`jackc/pgx`) for testing to keep the example code
simple. The main test suite `cmd/pggen/test` is parameterized over the driver though. It
allows you to you set the driver name via the `DB_DRIVER` environment variable. You can
either set this variable to `postgres` (to use `lib/pq`) or `pgx` (to use
`github.com/jackc/pgx/stdlib`).
`github.com/jackc/pgx/v4/stdlib`).

The `tools/test.bash` script runs the test suite both ways.

Expand Down
2 changes: 0 additions & 2 deletions cmd/pggen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"os"
"strings"

_ "github.com/lib/pq"

"github.com/opendoor-labs/pggen/gen"
)

Expand Down
1 change: 1 addition & 0 deletions cmd/pggen/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/json"
_ "github.com/jackc/pgx/v4/stdlib" // load driver
_ "github.com/lib/pq" // load driver (we still test against lib/pq)
"log"
"os"
"os/exec"
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.

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.

26 changes: 13 additions & 13 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.

6 changes: 3 additions & 3 deletions examples/json_columns/models/models.gen.go

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

6 changes: 3 additions & 3 deletions examples/middleware/models/models.gen.go

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

6 changes: 3 additions & 3 deletions examples/nullable_query_arguments/models/models.gen.go

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

6 changes: 3 additions & 3 deletions examples/query/models/models.gen.go

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

6 changes: 3 additions & 3 deletions examples/query_argument_names/models/models.gen.go

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

6 changes: 3 additions & 3 deletions examples/single_results/models/models.gen.go

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

Loading

0 comments on commit 97e8fea

Please sign in to comment.