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

feat: add "use_interface_return_types" option #3125

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

Conversation

Jesse0Michael
Copy link

  • Add the option "use_interface_return_types" to direct sqlc generation to use the querier interface for the return type of the WithTx method on the Queries struct.

  • Include WithTx in the Querier interface (when "emit_methods_with_db_argument" is false)


Looks to resolve #383

Where the lack of WithTx in the interface causes makes it hard to use the Querier interface
and the *Queries return type makes it hard to mock the sqlc Querier for testing

Please let me know if I should have approached this differently or if there's something else I need to do! ✌️

@Jesse0Michael
Copy link
Author

It would be nice if we could just update the WithTx signature to use "Querier" instead of "*Queries" if emit_interface is enabled.. but, as @kyleconroy mentions in the issue #383 (comment), that would be a breaking change.

My hope is that we could put the change behind an explicit option.

I imagine use_interface_return_types isn't a clear enough name for an option that would fix the function signature of WithTx, but instead of guessing what would be a clearer name, I'd rather be told would be an acceptable option name

Add an option to direct sqlc generation to use the querier interface for the return type of the WithTx method on the Queries struct.

Include WithTx in the Querier interface (when "emit_methods_with_db_argument" is false)
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.

WithTx is not part of the method set of interface generated
1 participant