You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've faced scenarios in which we had to mock the Querier interface, a practical example is to use a mocked implementation for unit tests. A fine-grained approach to mocking this interface is to have an in-memory mocked implementation of this interface. This not only can act as an implementation with high fidelity but also is so fast (since it's in-memory) that can be used in unit tests.
As models and queries change, keeping the mocked implementation is challenging. I've come up with an idea to solve this problem and I would like to share it to get informed about the project owners' opinions.
Since sqlc is a code-gen tool, my idea is to add an option to it to be able to also generate an in-memory mocked implementation. The basis of my idea is to have a struct having a list of each database table as its field. A practical example would be as follows:
In this way, we can implement each SQL query by aggregating these fields.
Let me know about your opinions on this idea and I really appreciate any recommendation. I'm also eager to make an MVP for Golang language if the idea get accepted.
What database engines need to be changed?
No response
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered:
@Adibov I think this is a great idea, but it's not going to fit into the main tool. It would work great as a plugin though. Happy to help show you how that works. Your starting point can be https://github.com/sqlc-dev/sqlc-gen-go.
What do you want to change?
We've faced scenarios in which we had to mock the
Querier
interface, a practical example is to use a mocked implementation for unit tests. A fine-grained approach to mocking this interface is to have an in-memory mocked implementation of this interface. This not only can act as an implementation with high fidelity but also is so fast (since it's in-memory) that can be used in unit tests.As models and queries change, keeping the mocked implementation is challenging. I've come up with an idea to solve this problem and I would like to share it to get informed about the project owners' opinions.
Since sqlc is a code-gen tool, my idea is to add an option to it to be able to also generate an in-memory mocked implementation. The basis of my idea is to have a struct having a list of each database table as its field. A practical example would be as follows:
In this way, we can implement each SQL query by aggregating these fields.
Let me know about your opinions on this idea and I really appreciate any recommendation. I'm also eager to make an MVP for Golang language if the idea get accepted.
What database engines need to be changed?
No response
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered: