Skip to content

Commit 4012073

Browse files
sqlc: introduce NewForType helper method
The upcoming implementation of `sqldb/v2` will extensively create a `Queries` object on the fly. To make more intuitive how to create the queries object for specific database types, we introduce a `NewForType` helper method. This also mimics how `tapd` creates the `Queries` object, and in order not let `litd` have it's own definition of how `Queries` object are created on the fly, the upcoming `sqldb/v2` usage will utilize this helper method.
1 parent d70cd76 commit 4012073

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

db/sqlc/db_custom.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ func NewPostgres(db DBTX) *Queries {
3636
return &Queries{db: &wrappedTX{db, sqldb.BackendTypePostgres}}
3737
}
3838

39+
// NewForType creates a new Queries instance for the given database type.
40+
func NewForType(db DBTX, typ sqldb.BackendType) *Queries {
41+
return &Queries{db: &wrappedTX{db, typ}}
42+
}
43+
3944
// CustomQueries defines a set of custom queries that we define in addition
4045
// to the ones generated by sqlc.
4146
type CustomQueries interface {

0 commit comments

Comments
 (0)