Repository navigation
feat(deps)!: migrate from pgx v4 to v5 - #18
Merged
Merged
Conversation
Migrate the jackc/pgx driver dependency from v4 to v5 to clear the two remaining Dependabot alerts that a dependency bump alone could not fix: - GHSA-jqcq-xjh3-6g23 (pgproto3/v2 DoS via negative field length): v5 no longer depends on the standalone jackc/pgproto3/v2 module at all. - GHSA-j88v-2chj-qfwx (pgx/v4 SQL injection via dollar-quoted string placeholder confusion): fixed upstream in pgx v5.9.2+; this pins pgx/v5 v5.10.0. BREAKING CHANGE: the Connection/Queryer/Transactor interfaces in pgxschema.go are now defined in terms of pgx/v5 types (pgx.Rows, pgx.Tx, pgx/v5/pgconn.CommandTag) instead of pgx/v4 equivalents. Consumers must update their imports from github.com/jackc/pgx/v4 (and the standalone github.com/jackc/pgconn module) to github.com/jackc/pgx/v5, and change pgxpool.Connect(...) call sites to pgxpool.New(...). No pgxschema function/method signatures changed otherwise. Also updates the pgxmock test dependency from v1 (pgx/v4-based) to v4 (pgx/v5-based), and fixes two test helpers whose v4-specific behavior didn't carry over: a []byte CommandTag return (v4 aliased CommandTag to []byte) and a zero-value CommandTag passed to WillReturnResult (pgxmock v4 treats an empty CommandTag.String() as 'result not set'). Closes #17
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 216 216
=========================================
Hits 216 216 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17
What changed
Migrates the
jackc/pgxdriver dependency from v4 to v5.Import paths:
github.com/jackc/pgx/v4->github.com/jackc/pgx/v5github.com/jackc/pgx/v4/pgxpool->github.com/jackc/pgx/v5/pgxpoolgithub.com/jackc/pgconn(standalone v4 module) ->github.com/jackc/pgx/v5/pgconn(now vendored inside pgx/v5)Public signatures changed (breaking surface): the
Connection,Queryer, andTransactorinterfaces inpgxschema.goare unchanged in shape, but their method signatures now reference pgx/v5 types instead of pgx/v4 types:Queryer.Exec(...) (pgconn.CommandTag, error)—pgconn.CommandTagis nowgithub.com/jackc/pgx/v5/pgconn.CommandTagQueryer.Query(...) (pgx.Rows, error)—pgx.Rowsis now the v5 interfaceTransactor.Begin(...) (pgx.Tx, error)—pgx.Txis now the v5 interfaceNo method names, parameter counts, or return shapes changed — only the underlying package versions of the pgx types involved.
Test-only changes: test helper call sites updated from
pgxpool.Connect(...)topgxpool.New(...)(renamed in pgx v5), and thepashagolub/pgxmocktest dependency bumped from v1 (pgx/v4-based) to v4 (pgx/v5-based).Why this clears the dependabot alerts
github.com/jackc/pgproto3/v2module at all — confirmed absent fromgo.mod/go.sumafter this change.github.com/jackc/pgx/v5 v5.10.0.(pgx v5.11.0 is also available but was intentionally avoided — see note below.)
This is a BREAKING change
Any consumer of pgxschema that passes a
pgx.Conn,pgxpool.Pool, orpgx.TxintoMigrator.Apply()orMigrator.GetAppliedMigrations()must update their own imports from pgx v4 to pgx v5 types, since those types no longer satisfy pgxschema's interfaces otherwise. This warrants a minor release (v1.3.0) once merged — not bumped or tagged here per instructions.Migration for consumers
Build / test results
Note on pgx/v5 version pin (v5.10.0, not latest v5.11.0)
pgx v5.11.0 added a
TypeMap()method to thepgx.Rowsinterface. The currentpashagolub/pgxmock/v4release (v4.9.0, built against pgx v5.7.4) does not implement it yet on its mockRows, which breaksgo vet/compilation of the test suite against v5.11.0 (tracked upstream: pashagolub/pgxmock#288). v5.10.0 satisfies the ">= 5.9.2" requirement for both advisory fixes and is fully compatible with the current pgxmock release. Worth revisiting once pgxmock addsTypeMap()support.Dependabot alert count
Alerts are evaluated against the default branch, so the count won't drop until this merges. Verified locally instead:
go list -m github.com/jackc/pgx/v5->v5.10.0(>= the 5.9.2 fix version)grep -rn 'pgx/v4' --include='*.go' .-> no matchesgrep -i pgproto3 go.sum-> no matches (module no longer in the dependency graph)