Skip to content
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

Return Querier interface from WithTx when interface is emitted. #3701

Open
0xstepit opened this issue Nov 10, 2024 · 0 comments
Open

Return Querier interface from WithTx when interface is emitted. #3701

0xstepit opened this issue Nov 10, 2024 · 0 comments
Labels
enhancement New feature or request 🔧 golang

Comments

@0xstepit
Copy link

What do you want to change?

When you specify the flag: emit_interface: true in the sqlc.yaml, the Querier interface is generated. This is a great feature, however, the WithTx method returns a *Queries pointer, making the use of the interface hard:

func (q *Queries) WithTx(tx *sql.Tx) *Queries {
	return &Queries{
		db: tx,
	}
}

It would be great to return the interface when the previously mentioned flag is set to true:

func (q *Queries) WithTx(tx *sql.Tx) Querier {
	return &Queries{
		db: tx,
	}
}

Happy to create a PR for it if you like the idea.

What database engines need to be changed?

No response

What programming language backends need to be changed?

Go

@0xstepit 0xstepit added the enhancement New feature or request label Nov 10, 2024
@dosubot dosubot bot added the 🔧 golang label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🔧 golang
Projects
None yet
Development

No branches or pull requests

1 participant