Skip to content

Remove lib/pq usage and rely on pgtype arrays#255

Closed
catatsuy wants to merge 1 commit into
stripe:mainfrom
catatsuy:feature-remove-lib-pq
Closed

Remove lib/pq usage and rely on pgtype arrays#255
catatsuy wants to merge 1 commit into
stripe:mainfrom
catatsuy:feature-remove-lib-pq

Conversation

@catatsuy

Copy link
Copy Markdown
Contributor

Description

  • Remove direct lib/pq usage and switch array decoding to pgtype while keeping pgx at v4
  • Tidy connection flag wording to reference libpq-compatible defaults
  • Update generated query helpers/comments accordingly

Motivation

  • Drop lib/pq without changing pgx version, continuing to support libpq-style env/DSN defaults

Testing

go test ./...

@bplunkett-stripe

Copy link
Copy Markdown
Contributor

I don't think this is really feasible because it requires changing all references from sql.X to pgx.X in order such that sqlc can rely on pgx types, meaning it would break for folks using this library.

I attempted that here. Is there a reason you are trying to do this?

@catatsuy

Copy link
Copy Markdown
Contributor Author

Hi, thanks for looking. @bplunkett-stripe

My reason is simple: lib/pq is basically unmaintained, so I think we should move away from it sooner.

I understand the concern about breaking users. I’m not trying to change the public API from database/sql (sql.*) to pgx.*. My goal is only to remove the lib/pq dependency and keep behavior compatible.

If my PR still breaks compatibility, I can adjust it. Would you prefer doing this behind a build tag or only in a major version bump?

@bplunkett-stripe

Copy link
Copy Markdown
Contributor

If my PR still breaks compatibility, I can adjust it. Would you prefer doing this behind a build tag or only in a major version bump?

Your PR doesn't work because sqlc still depends on pq's array type. I think we can make your PR work by just encoding it as JSON...in theory, that means sqlc no longer needs the pq type dependency. See my linked PR where I tried to switch to pgx.

@catatsuy

Copy link
Copy Markdown
Contributor Author

Thanks — that makes sense. @bplunkett-stripe

I didn’t realize sqlc still depends on pq’s array type, so my PR can’t fully remove the lib/pq dependency in a compatible way.

Your idea of encoding the array as JSON (so sqlc no longer needs pq types) sounds like a good direction, and your linked PR looks cleaner. I’m not confident enough to redesign this properly myself, so I’d prefer to follow your approach.

@bplunkett-stripe

Copy link
Copy Markdown
Contributor

Understood! I'll close this out, but feel free to re-open this PR and ping me if you'd like to make the change. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants