Skip to content

Commit

Permalink
Upgrade to pgx v5
Browse files Browse the repository at this point in the history
- For pggen row structs, implement pgx.RowScanner.
- Remove the typeResolver, since we're punting type resolution to the pgx.Conn
  type map for now.

#74
  • Loading branch information
jschaf committed Jan 5, 2024
1 parent 3259c9a commit b524213
Show file tree
Hide file tree
Showing 57 changed files with 346 additions and 455 deletions.
8 changes: 4 additions & 4 deletions example/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"
"flag"
"fmt"
"github.com/jackc/pgx/v4"
"github.com/jackc/pgx/v5"
"github.com/jschaf/pggen/internal/errs"
"github.com/jschaf/pggen/internal/pgdocker"
"math/rand"
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestExamples(t *testing.T) {
"--go-type", "int8=int",
"--go-type", "int4=int",
"--go-type", "text=string",
"--go-type", "citext=github.com/jackc/pgtype.Text",
"--go-type", "citext=github.com/jackc/pgx/v5/pgtype.Text",
},
},
{
Expand Down Expand Up @@ -179,8 +179,8 @@ func TestExamples(t *testing.T) {
args: []string{
"--schema-glob", "example/ltree/schema.sql",
"--query-glob", "example/ltree/query.sql",
"--go-type", "ltree=github.com/jackc/pgtype.Text",
"--go-type", "_ltree=github.com/jackc/pgtype.TextArray",
"--go-type", "ltree=github.com/jackc/pgx/v5/pgtype.Text",
"--go-type", "_ltree=github.com/jackc/pgx/v5/pgtype.TextArray",
},
},
{
Expand Down
94 changes: 33 additions & 61 deletions example/author/query.sql.go

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

2 changes: 1 addition & 1 deletion example/author/query.sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
"testing"

"github.com/jackc/pgx/v4"
"github.com/jackc/pgx/v5"
"github.com/jschaf/pggen/internal/pgtest"
"github.com/stretchr/testify/assert"
)
Expand Down
6 changes: 3 additions & 3 deletions example/complex_params/query.sql.go

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

2 changes: 1 addition & 1 deletion example/composite/codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestGenerate_Go_Example_Composite(t *testing.T) {
"int8": "int",
"int4": "int",
"text": "string",
"citext": "github.com/jackc/pgtype.Text",
"citext": "github.com/jackc/pgx/v5/pgtype.Text",
},
})
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions example/composite/query.sql.go

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

2 changes: 1 addition & 1 deletion example/composite/query.sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package composite

import (
"context"
"github.com/jackc/pgtype"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jschaf/pggen/internal/difftest"
"github.com/jschaf/pggen/internal/pgtest"
"github.com/jschaf/pggen/internal/ptrs"
Expand Down
6 changes: 3 additions & 3 deletions example/custom_types/query.sql.go

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

4 changes: 2 additions & 2 deletions example/custom_types/query.sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package custom_types

import (
"context"
"github.com/jackc/pgtype"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jschaf/pggen/internal/pgtest"
"github.com/jschaf/pggen/internal/texts"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -38,7 +38,7 @@ func TestQuerier_CustomMyInt(t *testing.T) {
AND pn.nspname = current_schema()
LIMIT 1;
`))
oidVal := pgtype.OIDValue{}
oidVal := uint32Value{}
err := row.Scan(&oidVal)
require.NoError(t, err)
t.Logf("my_int oid: %d", oidVal.Uint)
Expand Down
6 changes: 3 additions & 3 deletions example/device/query.sql.go

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

2 changes: 1 addition & 1 deletion example/device/query.sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package device

import (
"context"
"github.com/jackc/pgtype"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jschaf/pggen/internal/pgtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
6 changes: 3 additions & 3 deletions example/domain/query.sql.go

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

6 changes: 3 additions & 3 deletions example/enums/query.sql.go

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

2 changes: 1 addition & 1 deletion example/enums/query.sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package enums

import (
"context"
"github.com/jackc/pgtype"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jschaf/pggen/internal/pgtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
6 changes: 3 additions & 3 deletions example/erp/order/customer.sql.go

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

2 changes: 1 addition & 1 deletion example/erp/order/customer.sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package order

import (
"context"
"github.com/jackc/pgtype"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jschaf/pggen/internal/pgtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion example/erp/order/price.sql.go

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

6 changes: 3 additions & 3 deletions example/function/query.sql.go

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

Loading

0 comments on commit b524213

Please sign in to comment.