-
Notifications
You must be signed in to change notification settings - Fork 841
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
go: expose DBTX inside Queries (via flag) #3273
Comments
Why don't you add a receiver function in a new file inside the generated package? We do something similar when we have to deal with transactions outside the generated package. func (q *Queries) Pool() *pgxpool.Pool {
return q.db.(*pgxpool.Pool)
} We also add receiver functions for raw queries that are currently not being able to be interpreted by sqlc. |
That's my current workaround, at the cost of sqlc's "out" folder no longer being 100% autogenerated thus it can't be blindly deleted anymore. |
Have you also considered using |
I don't think so, I'll give it a try this afternoon. EDIT: Tried, that flag does "the opposite" of what I want. It requires a I just need the underlying |
@toqueteos, this is ideal way, suppose you have to work in application where Even though, in certain edge case like you are facing, there is need for making this @kyleconroy @francesconi, Should I raise the PR for this issue by adding new configuration key for it? |
What do you want to change?
Currently the autogenerated
db.go
file contains this two types: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:
db
public by renaming it toDB
What database engines need to be changed?
None
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered: