-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What do you want to change?
Currently the autogenerated db.go file contains these two types:
type DBTX interface {
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
QueryRow(context.Context, string, ...interface{}) pgx.Row
}
// [..]
type Queries struct {
db DBTX
}Sometimes, because of ✨ questionable business reasons ✨ we would like to use the DBTX inside a *Queries to write some raw SQL but currently that's not possible.
An escape hatch behind a flag, something like emit_public_dbtx, to allow this would be very welcome.
Options for the changes required:
- A) Embed DBTX inside Queries
type Queries struct {
DBTX
}- B) Make
dbpublic by renaming it toDB
type Queries struct {
DB DBTX
}- C) Add a new method to Queries which exposes the DBTX (this option requires the least changes)
// There might be better names than Conn, I'm open to suggestions
func (q *Queries) Conn() DBTX {
return q.db
}What database engines need to be changed?
None
What programming language backends need to be changed?
Go
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request