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
proposal: Go 2: database/sql: Prepare and QueryRow to return Statement and Row interface #22626
Comments
I think will better returns interfaces from all methods |
CC @kardianos |
We can't change the signature of |
Of course. How'bout in Go2? |
In Go 2 we could make such a change, but it should ideally be part of an overhaul of the database/sql package in general. |
@andizzle Please read my comment here: In essence, for Go2 I would like to separate out preparing a statement on a given connection from the Stmt connection pool. Then the user can handle these situations themselves. They can call conn.Prepare, and the returned stmt is specific to that connection. |
Closing this specific issue in favor of the more general #22697. |
Have a
Stmt interface
gives developer more controls when writing database related tools. It would be nice to to be able to create a custom stmt struct that has the same method signatures assql.Stmt
but with some custom instructions inside each method. For example, when writing a DB wrapper for handling database read replicas, the statement may need to be prepared in multiple db pools, to provide a seamless feel for the end users, I woulld like the users to call thePrepare()
orPrepareContext()
as if they are usingdatabase/sql.DB
.example usecase
In some rare cases we would like to include some custom errors when using
QueryRow
. Take read replica situation as an example again, if the tool wants to provide the customQueryRow
function but need to capture certain errors, it would be nice to return aRow
interface instead of panicing.example usecase
The text was updated successfully, but these errors were encountered: