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
Usecase is to have seperate set of queries generated for read access and write access.
For example if I have read user of Mysql , I will not be able to prepare the update , insert statement from it because sqlc generates everything in one compiled list of queries.
The solution is to generate two separate prepared folder but then it would result in lot of code duplication of models also getting generated.
Can we have a solution where we can get the objects in separate set of queries which could be used to prepare from corresponding db users.
Current Behaviour :
-- name: SelectTable
Select * from table;
-- name: InsertTable
Insert into Table values (1,2,3);
output generated from it
type Queries struct {
db DBTX
tx *sql.Tx
selectTable *sql.Stmt
insertTable *sql.Stmt
}
Now I cant use this Queries struct with my read db user and it fails during the prepare method call becase the queries have both select and insert queries.
Feature request : On generate command it should generate something like
type ReadQueries struct {
selectTable *sql.Stmt
}
type WriteQueries struct {
insertTable *sql.Stmt
}
and these corresponding queries can be used with corresponding mysql db users context while preparing.
What database engines need to be changed?
PostgreSQL, MySQL, SQLite
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered:
It's an interesting idea. We've kicked around generating different interfaces for reader and writers, but that wouldn't solve your issue as you're preparing the queries before hand. The best I can offer right now is moving the read-only queries into a separate query file and create two different packages.
@kyleconroy , we currently thought of doing what you suggested , but It is resulting in lot of code duplication in terms of models that we being generated.
What do you want to change?
Usecase is to have seperate set of queries generated for read access and write access.
For example if I have read user of Mysql , I will not be able to prepare the update , insert statement from it because sqlc generates everything in one compiled list of queries.
The solution is to generate two separate prepared folder but then it would result in lot of code duplication of models also getting generated.
Can we have a solution where we can get the objects in separate set of queries which could be used to prepare from corresponding db users.
Current Behaviour :
output generated from it
Now I cant use this Queries struct with my read db user and it fails during the prepare method call becase the queries have both select and insert queries.
Feature request : On generate command it should generate something like
and these corresponding queries can be used with corresponding mysql db users context while preparing.
What database engines need to be changed?
PostgreSQL, MySQL, SQLite
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered: