Skip to content

pgx: don't use database/sql interface #1198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

serprex
Copy link

@serprex serprex commented Nov 29, 2024

it'd be nice to have contexts for many of these methods, but that'd be a much wider change

it'd be nice to have contexts for many of these methods, but that'd be a much wider change
@joschi
Copy link
Contributor

joschi commented Dec 9, 2024

it'd be nice to have contexts for many of these methods

See also #1132.

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isLocked atomic.Bool

// Open and WithInstance need to guarantee that config is never nil
config *Config
}

func WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {
func WithInstance(instance *pgx.Conn, config *Config) (database.Driver, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. Can you convert the sql.DB to a pgx.Conn internally?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to expose a new method for people who want to pass *pgx.Conn directly

You can get *pgx.Conn from *sql.DB potentially with conn, ok := db.Conn().(*pgx.Conn)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into, db.Conn() is itself a wrapper around the driver provided connection. & does not expose handing off underlying connection

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.

4 participants